title: convert a dict to sorted dict in python
body: <p>I want to convert a dict into sorted dict in python</p>
  
  <pre><code>data = pandas.read_csv('D:\myfile.csv')
  for colname, dtype in data.dtypes.to_dict().iteritems():
      if dtype == 'object':
          print colname
          count = data[colname].value_counts()
          d = dict((str(k), int(v)) for k, v in count.iteritems())
          f = dict(sorted(d.iteritems(), key=lambda item: item[1], reverse = True)[:5])
          print f
  
          m ={}
          m["count"]= int(sum(count))    
          m["Top 5"]= f    
          print m    
          k = json.dumps(m)
          print k    
  f = {'Gears of war 3': 6, 'Batman': 5, 'gears of war 3': 4, 'Rocksmith': 5, 'Madden': 3}
  </code></pre>
  
  <p>My desired Output is :</p>
  
  <pre><code>f = {'Gears of war 3': 6, 'Batman': 5, 'Rocksmith': 5, 'gears of war 3': 4, 'Madden': 3}
  k = {'count':24, 'top 5':{'Gears of war 3': 6, 'Batman': 5, 'Rocksmith': 5, 'gears of war 3': 4, 'Madden': 3}}
  </code></pre>
  
  <p>(in the descending order of values and the result should be a dict)</p>