nodes: 0, module; 1, function_definition; 2, function_name:sorted_tree; 3, parameters; 4, block; 5, identifier:tree; 6, expression_statement; 7, return_statement; 8, comment:"""Sorts the dict representation of the tree
  
      The root packages as well as the intermediate packages are sorted
      in the alphabetical order of the package names.
  
      :param dict tree: the pkg dependency tree obtained by calling
                       `construct_tree` function
      :returns: sorted tree
      :rtype: collections.OrderedDict
  
      """; 9, call; 10, identifier:OrderedDict; 11, argument_list; 12, call; 13, identifier:sorted; 14, argument_list; 15, list_comprehension; 16, keyword_argument; 17, tuple; 18, for_in_clause; 19, identifier:key; 20, lambda; 21, identifier:k; 22, call; 23, pattern_list; 24, call; 25, lambda_parameters; 26, attribute; 27, identifier:sorted; 28, argument_list; 29, identifier:k; 30, identifier:v; 31, attribute; 32, argument_list; 33, identifier:kv; 34, subscript; 35, identifier:key; 36, identifier:v; 37, keyword_argument; 38, identifier:tree; 39, identifier:items; 40, identifier:kv; 41, integer:0; 42, identifier:key; 43, call; 44, identifier:attrgetter; 45, argument_list; 46, string; 47, string_content:key
code: def sorted_tree(tree):
      """Sorts the dict representation of the tree
  
      The root packages as well as the intermediate packages are sorted
      in the alphabetical order of the package names.
  
      :param dict tree: the pkg dependency tree obtained by calling
                       `construct_tree` function
      :returns: sorted tree
      :rtype: collections.OrderedDict
  
      """
      return OrderedDict(sorted([(k, sorted(v, key=attrgetter('key')))
                                 for k, v in tree.items()],
                                key=lambda kv: kv[0].key))