sort dict by value python
To get the values use
<span class="pln">sorted</span><span class="pun">(</span><span class="pln">data</span><span class="pun">.</span><span class="pln">values</span><span class="pun">())</span>
To get the matching keys, use a key
function
<span class="pln">sorted</span><span class="pun">(</span><span class="pln">data</span><span class="pun">,</span><span class="pln"> key</span><span class="pun">=</span><span class="pln">data</span><span class="pun">.</span><span class="pln">get</span><span class="pun">)</span>
To get a list of tuples ordered by value
<span class="pln">sorted</span><span class="pun">(</span><span class="pln">data</span><span class="pun">.</span><span class="pln">items</span><span class="pun">(),</span><span class="pln"> key</span><span class="pun">=</span><span class="kwd">lambda</span><span class="pln"> x</span><span class="pun">:</span><span class="pln">x</span><span class="pun">[</span><span class="lit">1</span><span class="pun">])</span>