def _toposort_modules(module_list):
    """Topologically sorts Python classes.

    Takes a list of Python classes and returns them sorted topologically wrt
    the subclass relation, such that if `a` and `b` are both in the list and
    ``issubclass(a, b)``, then `a` will appear before `b` in the result.
    """

    g = Graph()
    for m in module_list:
        if isinstance(m, tuple):
            g.add_vertex(m[0], m)
        else:
            g.add_vertex(m, m)
    for m in module_list:
        if isinstance(m, tuple):
            m = m[0]
        for subclass in m.mro()[1:]: # skip self
            if subclass in g.vertices:
                g.add_edge(subclass, m)
    return [g.vertices[v] for v in g.vertices_topological_sort()]
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/modules/module_registry.py/_toposort_modules/original