title: How do I sort an array in jQuery?
body: <p>I am using an array to store occurrences of specific words in a text. The format of the data is word:number.
  I would like to sort the array by descending number of occurrences (ie. by value).
  Is there a neat way to do it? Or should I consider using a different data structure?</p>
  
  <pre><code>// This is how the array is filled.
  var matches = ["word1", "word2", "word2", "word3", "word4", "word4", "word4"];  
  
  var count = {};
  $.each(matches, function(key, value) {
      if(!count[value])
          count[value] = 1;
      else
          count[value]++;
  });
  </code></pre>
  
  <p>After the loop this is what I get and want to sort by descending values:</p>
  
  <pre><code>count = { 'word1':'1', 'word2':'2', 'word3':'1', 'word4':'3' };
  </code></pre>
  
  <p>What I actually want it to look like (sorted by value):</p>
  
  <pre><code>count = { 'word4':'3', 'word2':'2', 'word1':'1', 'word3':'1' };
  </code></pre>