title: How to properly sort a dictionary by value of a key?
body: <p>I would like to sort a dictionary by value of specific key (&quot;foo&quot; in the example)</p>
  <pre><code>mydict = dict()
  mydict[&quot;a&quot;] = {&quot;foo&quot;: 0.3, &quot;boo&quot;: 0.1}
  mydict[&quot;b&quot;] = {&quot;foo&quot;: 0.1, &quot;boo&quot;: 0.2}
  mydict[&quot;c&quot;] = {&quot;foo&quot;: 0.8, &quot;boo&quot;: 0.3}
  mydict[&quot;d&quot;] = {&quot;foo&quot;: 0.5, &quot;boo&quot;: 0.4}
  mydict[&quot;e&quot;] = {&quot;foo&quot;: 0.2, &quot;boo&quot;: 0.5}
  
  # sort by &quot;foo&quot; in descending order
  # expected result: [{&quot;foo&quot;: 0.8, &quot;boo&quot;: 0.3}, {&quot;foo&quot;: 0.5, &quot;boo&quot;: 0.4}, {&quot;foo&quot;: 0.3, &quot;boo&quot;: 0.1}, {&quot;foo&quot;: 0.2, &quot;boo&quot;: 0.5}, {&quot;foo&quot;: 0.1, &quot;boo&quot;: 0.2}]
  </code></pre>
  <p>How can I get the result I want like shown in the comment above?</p>