public void order()

in src/main/java/org/junit/runners/ParentRunner.java [477:510]


    public void order(Orderer orderer) throws InvalidOrderingException {
        if (shouldNotReorder()) {
            return;
        }

        childrenLock.lock();
        try {
            List<T> children = getFilteredChildren();
            // In theory, we could have duplicate Descriptions. De-dup them before ordering,
            // and add them back at the end.
            Map<Description, List<T>> childMap = new LinkedHashMap<Description, List<T>>(
                    children.size());
            for (T child : children) {
                Description description = describeChild(child);
                List<T> childrenWithDescription = childMap.get(description);
                if (childrenWithDescription == null) {
                    childrenWithDescription = new ArrayList<T>(1);
                    childMap.put(description, childrenWithDescription);
                }
                childrenWithDescription.add(child);
                orderer.apply(child);
            }

            List<Description> inOrder = orderer.order(childMap.keySet());

            children = new ArrayList<T>(children.size());
            for (Description description : inOrder) {
                children.addAll(childMap.get(description));
            }
            filteredChildren = Collections.unmodifiableList(children);
        } finally {
            childrenLock.unlock();
        }
    }