@SafeVarargs
    static <T> List<T> ordered(Collection<T> items, Class<? extends T>... order) {
        List<T> ordered = new ArrayList<>(items);
        ordered.sort(Comparator.comparingInt(item -> {
            int best = order.length;
            for (int i = 0; i < order.length; i++) {
                if (   order[i].isInstance(item)
                    && (   best == order.length
                        || order[best].isAssignableFrom(order[i]))) best = i;
            }
            return  best;
        }));
        return ordered;
    }
Returns a list with the given elements, ordered by the enumerated classes, ordering more specific matches first.
container-disc/src/main/java/com/yahoo/container/jdisc/ConfiguredApplication.java