title: Sort PHP Array by number of Appearances
body: <p>In short I'd like to order an array by the number of times each member turns up, then remove duplicates.</p>
  
  <p>So this:</p>
  
  <pre><code>$array = array('s', 'h', 'c', 'b', 'a', 'b', 'd', 'e', 'f', 'f', 'g')
  </code></pre>
  
  <p>Would first be ordered:</p>
  
  <pre><code>('b', 'b', 'f', 'f', 's', 'h', 'c', 'a', 'd', 'e', 'g')
  </code></pre>
  
  <p>And then have the duplicates removed:</p>
  
  <pre><code>$array = array_unique($array);
  </code></pre>
  
  <p>And look like this:</p>
  
  <pre><code>('b', 'f', 's', 'h', 'c', 'a', 'd', 'e', 'g')
  </code></pre>
  
  <p>So, how do I do this? Thanks in advance.</p>