parameters: (data)
docstring: Topological sort.
      From http://code.activestate.com/recipes/577413-topological-sort/
      This function is under the MIT license.
docstring_summary: Topological sort.
      From http://code.activestate.com/recipes/577413-topological-sort/
      This function is under the MIT license.
docstring_tokens: Topological sort . From http : // code . activestate . com / recipes / 577413 - topological - sort / This function is under the MIT license .
function: def toposort2(data):
      '''Topological sort.
      From http://code.activestate.com/recipes/577413-topological-sort/
      This function is under the MIT license.
      '''
      for k, v in list(data.items()):
          v.discard(k) # Ignore self dependencies
      extra_items_in_deps = reduce(set.union, list(data.values()), set()) - set(data.keys())
      data.update(dict([(item, set()) for item in extra_items_in_deps]))
      while True:
          ordered = set(item for item,dep in list(data.items()) if not dep)
          if not ordered:
              break
          for item in sorted(ordered):
              yield item
          data = dict([(item, (dep - ordered)) for item,dep in list(data.items())
                  if item not in ordered])
      assert not data, "A cyclic dependency exists amongst %r" % data
function_tokens: def toposort2 ( data ) : for k , v in list ( data . items ( ) ) : v . discard ( k ) # Ignore self dependencies extra_items_in_deps = reduce ( set . union , list ( data . values ( ) ) , set ( ) ) - set ( data . keys ( ) ) data . update ( dict ( [ ( item , set ( ) ) for item in extra_items_in_deps ] ) ) while True : ordered = set ( item for item , dep in list ( data . items ( ) ) if not dep ) if not ordered : break for item in sorted ( ordered ) : yield item data = dict ( [ ( item , ( dep - ordered ) ) for item , dep in list ( data . items ( ) ) if item not in ordered ] ) assert not data , "A cyclic dependency exists amongst %r" % data