title: Is it possible to initialize an empty OrderedDict in Python with a predefined sorting mechanism?
body: <p>All examples I could find (<a href="https://docs.python.org/2/library/collections.html#collections.OrderedDict" rel="noreferrer">in the documentation</a>, etc.) define OrderedDicts by passing data to the constructor. From the docs:</p>
  
  <pre><code># regular unsorted dictionary
  d = {'banana': 3, 'apple':4, 'pear': 1, 'orange': 2}
  
  # dictionary sorted by key
  OrderedDict(sorted(d.items(), key=lambda t: t[0]))
  OrderedDict([('apple', 4), ('banana', 3), ('orange', 2), ('pear', 1)])
  </code></pre>
  
  <p>On the other hand, it is possible to initialize an OrderedDict by providing no parameters to the constructor, which leads it to preserve the order in which key,value pairs are added.</p>
  
  <p>I am looking for a kind of construct that resembles the following, except without "d.items()". Essentially, I'm asking it to remember a mechanism without providing it an example, which might sound crazy. Is my only option to "hack" this by providing an initial "d" (below) with a single item, or is there a better way?</p>
  
  <pre><code>OrderedDict(sorted(d.items(), key=lambda t: t[0]))
  </code></pre>
  
  <p>Thank you!</p>