/**
 * JLibs: Common Utilities for Java
 * Copyright (C) 2009  Santhosh Kumar T
 * <p/>
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * <p/>
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */

package jlibs.core.graph.visitors;

import jlibs.core.graph.Sequence;
import jlibs.core.graph.WalkerUtil;
import jlibs.core.graph.sequences.FilteredSequence;
import jlibs.core.graph.sequences.IterableSequence;
import jlibs.core.graph.Filter;
import jlibs.core.graph.Navigator;

import java.util.List;
import java.util.Collection;

/**
 * @author Santhosh Kumar T
 */
public class ClassSorter{
    public static List<Class<?>> sort(final Sequence<Class<?>> classes){
        return WalkerUtil.topologicalSort(classes, new Navigator<Class<?>>(){
            @Override
            public Sequence<Class<?>> children(final Class<?> parent){
                return new FilteredSequence<Class<?>>(classes.copy(), new Filter<Class<?>>(){
                    @Override
                    public boolean select(Class<?> child){
                        return child.isAssignableFrom(parent);
                    }
                });
            }
        });
    }

    public static List<Class<?>> sort(Collection<Class<?>> classes){
        return sort(new IterableSequence<Class<?>>(classes));
    }
}

@@ -644,16 +644,83 @@
 itors;%0A%0A
+import jlibs.core.graph.Filter;%0Aimport jlibs.core.graph.Navigator;%0A
 import j
@@ -881,32 +881,33 @@
 leSequence;%0A
+%0A
 import j
 libs.core.gr
@@ -898,118 +898,50 @@
 rt j
-libs.core.graph.Filter;%0Aimport jlibs.core.graph.Navigator;%0A%0Aimport java.util.List;%0Aimport java.util.Collection
+ava.util.Collection;%0Aimport java.util.List
 ;%0A%0A/
@@ -1458,16 +1458,33 @@
   return
+ child!=parent &&
  child.i

exclude parent class in finding children