title: Most efficient way to order an array of Strings by frequency
body: <p>I have an array of Strings:</p>
  
  <pre><code>String[] stringArray = {"x", "y", "z", "x", "x", "y", "a"};
  </code></pre>
  
  <p>What is the quickest/most efficient way to order this into a smaller <code>Collection</code> in order of how frequent each <code>String</code> is with its frequency?</p>
  
  <p>I though about using the <code>String</code> as a key in a <code>HashMap&lt;String,Integer&gt;</code> but this wouldnt be sorted in terms of frequency</p>
  
  <p>My other method i considered is using a <code>TreeMap&lt;Integer, String[]&gt;</code> with a list of Strings with that integer, but there seems a lot of checking involved..</p>
  
  <p>Im trying to avoid using more than one loop If possible as my <code>String</code> arrays will be much larger than the one above. Thanks!</p>
  
  <p><strong>EDIT</strong>
  What i want is just to be able to output the Strings in order of frequency and preferably be able to pair that String with its frequency in the array, So for example two output arrays:</p>
  
  <pre><code>["x", "y", "z", "a"]
  [3,2,1,1]
  </code></pre>
  
  <p>This would be quite a simple problem if speed wasnt an issue which is why i ask the great minds on here :)</p>