code: def mapping_items(mapping, /):
      """Return an iterator over the ``mapping`` items,
          sort if it's a plain dict.
  
      >>> list(mapping_items({'spam': 0, 'ham': 1, 'eggs': 2}))  # doctest: +NO_EXE
      [('eggs', 2), ('ham', 1), ('spam', 0)]
  
      >>> from collections import OrderedDict
      >>> list(mapping_items(OrderedDict(enumerate(['spam', 'ham', 'eggs']))))
      [(0, 'spam'), (1, 'ham'), (2, 'eggs')]
      """
      result = iter(mapping.items())
      if type(mapping) is dict:
          result = iter(sorted(result))
      return result
  
file_path: graphviz/graphviz/_tools.py
imports: import functools
  import inspect
  import itertools
  import logging
  import os
  import pathlib
  import typing
  import warnings
label_desc: Use image node_id 3 for calling a global function with example usage: mapping_items() and returns: result