title: Sort nested dictionary by value, and remainder by another value, in Python
body: <p>Consider this dictionary format.</p>
  
  <pre><code>{'KEY1':{'name':'google','date':20100701,'downloads':0},
   'KEY2':{'name':'chrome','date':20071010,'downloads':0},
   'KEY3':{'name':'python','date':20100710,'downloads':100}}
  </code></pre>
  
  <p>I'd like the dictionary sorted by downloads first, and then all items with no downloads sorted by date. Obviously a dictionary cannot be sorted, I just need a sorted listed of keys I can iterate over. </p>
  
  <pre><code>['KEY3','KEY1','KEY2']
  </code></pre>
  
  <p>I can already sort the list by either value using <code>sorted</code>, but how do I sort by second value too? </p>