title: lambda in python can iterate dict?
body: <p>I have an interview recently. The interviewer asked me the ways to iterate dict in <code>python</code>. I said all the ways use <strong>for</strong> statement. But he told me that how about <strong>lambda</strong>?</p>
  
  <p>I feel confused very much and I consider lambda as an anonymity function, but how it iterates a dict? some code like this:</p>
  
  <pre><code>new_dict = sorted(old_dict.items(), lambda x: x[1]) # sorted by value in dict
  </code></pre>
  
  <p>But in this code, the lambda is used as a function to provide the compared key. What do you think this question?</p>