nodes: 0, module; 1, function_definition; 2, function_name:mapping_items; 3, parameters; 4, block; 5, identifier:mapping; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, return_statement; 10, identifier:_iteritems; 11, attribute; 12, comment:"""Return an iterator over the ``mapping`` items, sort if it's a plain dict.
  
      >>> list(mapping_items({'spam': 0, 'ham': 1, 'eggs': 2}))
      [('eggs', 2), ('ham', 1), ('spam', 0)]
  
      >>> from collections import OrderedDict
      >>> list(mapping_items(OrderedDict(enumerate(['spam', 'ham', 'eggs']))))
      [(0, 'spam'), (1, 'ham'), (2, 'eggs')]
      """; 13, comparison_operator:type(mapping) is dict; 14, block; 15, call; 16, identifier:_compat; 17, identifier:iteritems; 18, call; 19, identifier:dict; 20, return_statement; 21, identifier:_iteritems; 22, argument_list; 23, identifier:type; 24, argument_list; 25, call; 26, identifier:mapping; 27, identifier:mapping; 28, identifier:iter; 29, argument_list; 30, call; 31, identifier:sorted; 32, argument_list; 33, call; 34, identifier:_iteritems; 35, argument_list; 36, identifier:mapping
code: def mapping_items(mapping, _iteritems=_compat.iteritems):
      """Return an iterator over the ``mapping`` items, sort if it's a plain dict.
  
      >>> list(mapping_items({'spam': 0, 'ham': 1, 'eggs': 2}))
      [('eggs', 2), ('ham', 1), ('spam', 0)]
  
      >>> from collections import OrderedDict
      >>> list(mapping_items(OrderedDict(enumerate(['spam', 'ham', 'eggs']))))
      [(0, 'spam'), (1, 'ham'), (2, 'eggs')]
      """
      if type(mapping) is dict:
          return iter(sorted(_iteritems(mapping)))
      return _iteritems(mapping)