parameters: (messages)
docstring: Sort a list of Messages based on dependencies.
docstring_summary: Sort a list of Messages based on dependencies.
docstring_tokens: Sort a list of Messages based on dependencies .
function: def sort_dependencies(messages):
      '''Sort a list of Messages based on dependencies.'''
      dependencies = {}
      message_by_name = {}
      for message in messages:
          dependencies[str(message.name)] = set(message.get_dependencies())
          message_by_name[str(message.name)] = message
  
      for msgname in toposort2(dependencies):
          if msgname in message_by_name:
              yield message_by_name[msgname]
function_tokens: def sort_dependencies ( messages ) : dependencies = { } message_by_name = { } for message in messages : dependencies [ str ( message . name ) ] = set ( message . get_dependencies ( ) ) message_by_name [ str ( message . name ) ] = message for msgname in toposort2 ( dependencies ) : if msgname in message_by_name : yield message_by_name [ msgname ]