Why is 'key' function appended to the end of my OrderedDict when sorting? : <p>I am using python 3.6.5 and I am sorting an <code>OrderedDict</code>, e.g. <code>tmp.py</code>:</p>

<pre><code>from collections import OrderedDict
d = OrderedDict()
d[6] = 'a'
d[5] = 'b'
d[3] = 'c'
d[4] = 'd'
print(d)
print("keys : {}".format(d.keys()))
d = OrderedDict(sorted(d.items()), key=lambda t: t[1])
print(d)
print("keys : {}".format(d.keys()))
</code></pre>

<p>When I run <code>tmp.py</code>, I get :</p>

<pre><code>OrderedDict([(6, 'a'), (5, 'b'), (3, 'c'), (4, 'd')])
keys : odict_keys([6, 5, 3, 4])
OrderedDict([(3, 'c'), (4, 'd'), (5, 'b'), (6, 'a'), ('key', &lt;function &lt;lambda&gt; at 0x2ab444506bf8&gt;)])
keys : odict_keys([3, 4, 5, 6, 'key'])
</code></pre>

<p>Clearly the process of sorting has appended the <code>key()</code> function to my new <code>OrderedDict</code>.  I believe that I am sorting this in the same fashion prescribed in <a href="https://stackoverflow.com/a/8031431/4021436">this</a> post.</p>

<p><strong>QUESTION</strong> : 
Why does this happen and how to I properly sort an <code>OrderedDict</code>?  </p>
