title: Sorting dictionary by values in python
body: <p>I have a dictionary with key as words and values as ints.</p>
  
  <p>Is it possible to sort the dictionary by values?</p>
  
  <p>I want to be able to take the top 10 most occurring words in my dictionary. The values represent the word counts and the keys represent the word.</p>
  
  <pre><code>counter = 9
  for a,b in sorted(dict_.iteritems()):
          if counter &gt; 0:
              print str(a),str(b)+"\n"
              counter-=1
  </code></pre>
  
  <p>This is what i have so far but it is only printing off the first 10 items in the dictionary. How would I print off the top 10 most frequent items? (ie The values with the highest int as the value?)</p>