public List<Schema> order(List<Schema> unordered) {
        // No, this is not a fast algorithm...
        indexOnDocumentName(unordered);
        List<Schema> ordered = new ArrayList<>(unordered.size());
        List<Schema> moveOutwards = new ArrayList<>();
        for (Schema schema : unordered) {
            if (allDependenciesAlreadyEmitted(ordered, schema)) {
                addOrdered(ordered, schema, moveOutwards);
            }
            else {
                moveOutwards.add(schema);
            }
        }

        // Any leftovers means we have search definitions with undefined inheritants.
        // This is warned about elsewhere.
        ordered.addAll(moveOutwards);

        documentNameToSearch.clear();
        return ordered;
    }
Reorders the given list of search definitions such that any supertype
always preceed any subtype. Subject to this condition the given order
is preserved (the minimal reordering is done).

@return a new list containing the same search instances in the right order
config-model/src/main/java/com/yahoo/schema/derived/SearchOrderer.java