title: Python complicated dictionary sorting
body: <p>I have a dictionary, of which every key is holding a list as a value. Each list has one or more tuples with 2 items inside, one integer, one string.</p>
  
  <p>Example:</p>
  
  <pre><code>my_dict = {'dict_key_1': [(100, 'string_x1234'), (95, 'string_rtx3') ..],
             'dict_key_2': [(26, 'string_abc3'), (321, 'string_432fd'), ...],
             'dict_key_3': [(32, 'string_232df']}
  </code></pre>
  
  <p>I am iterating through this dictionary, and whilst doing that through items in the list.</p>
  
  <p>However, in both iterations I must have the dictionary sorted by the highest value of the first item of any tuple in the list.</p>
  
  <p>So in that case, since <strong>321</strong> is highest, I would get <strong>dict_key_2</strong> first, and its items would be listed starting with the tuple of which first item is <strong>321</strong>, then <strong>26</strong> and so on.</p>
  
  <p>I am fine with the second iteration (sorting the list of tuples) with:</p>
  
  <pre><code>sorted(data[k], reverse = True)
  </code></pre>
  
  <p>But I currently fail at sorting the main dictionary depending on the highest value of any tuple in the list that that key of dictionary is holding. I currently have:</p>
  
  <pre><code>for k in sorted(data, key=lambda k: sorted(data[k])[0][0]):
  </code></pre>
  
  <p>However, it is not working. But when I try to print <code>sorted(data[k])[0][0])</code> whilst iterating, it does indeed give the first value [0] of first tuple [0] after having it ordered on the first values of all tuples in that list (<code>data[k]</code>)</p>
  
  <p>What am I doing wrong? How can I get this dictionary sorted as needed?</p>
  
  <p>Thank you.</p>