title: JavaScript sort Array by uniqueness
body: <p>I have an array of items. For example:</p>
  
  <pre><code>var classes = ['link', 'block', 'hide', 'link', 'menu', 'block', 'content', 'link', 'footer', 'img', 'img', 'link', 'modal', 'button', 'form', 'input', 'button', 'input', 'link', 'toString', 'valueOf', 'button'];
  </code></pre>
  
  <p>I need to get an array of unique items, sorted by frequency:</p>
  
  <p><code>'link'</code> item should be in the first place, because array contain it 5 times.</p>
  
  <p><code>'button'</code> item should be in the second place, because array contain it 3 times.</p>
  
  <p>etc</p>
  
  <pre><code>["link", "button", "input", "img", "block", "footer", "content", "modal", "menu", "form", "hide", "toString", "valueOf"]
  </code></pre>