How does this code sort a dictionary?
<p>I was looking for ways to sort a dictionary and came across this code on a <a href="http://stackoverflow.com/questions/613183/python-sort-a-dictionary-by-value">SO thread</a>:</p>

<pre><code>import operator
x = {1: 2, 3: 4, 4:3, 2:1, 0:0}
sorted_x = sorted(x.iteritems(), key=operator.itemgetter(1))
</code></pre>

<p>How does this code work?
When I call iteritems() over a dictionary I get this:</p>

<pre><code>&lt;dictionary-itemiterator object at 0xf09f18&gt;
</code></pre>

<p>I know that this is a reference, but how do you use it?
And afaik, in sorted(a,b), as is supposed to be the thing you want to sort, and b would be the indicator for sorting right? How does itemgetter(1) work here?</p>
