title: Is it possible to sort a dict by datetime value, "exceptions.TypeError: can't compare datetime.datetime to unicode"
body: <p>I have a dict that I want to sort by the value of key 'entry_date' which is a datetime value.
  Most of the examples of sorting a dict are focused on numerical keys rather than string keys, and
  also primitive values rather than complex object values.</p>
  <p>I'd appreciate some help in adapting the sort for my particular problem.</p>
  <pre><code>data = {&quot;entry_date&quot;: datetime.now(), &quot;thisdata&quot;: &quot;foo&quot;, &quot;thatdata&quot;: &quot;bar&quot;}  # The code is 2.7
  print(sorted(data.items(), key = lambda x: x[1]))
  
  exceptions.TypeError: can't compare datetime.datetime to unicode
  </code></pre>
  <p>My guess is that I need to convert the entry_date value to a string? But:</p>
  <pre><code>print(sorted(data.items(), key = lambda x: x[1].strptime(dateFormat)))
  </code></pre>
  <p>is clearly not going to work. Some values in the dict are primitives.
  Perhaps I am expecting Python to do work that I need to be doing?</p>