title: Data Structure to sort elements by values
body: <p>I need a data structure in Java that can manipulate <code>String</code>s, compute the frequency of each word in an <code>ArrayList&lt;String&gt;</code> and then I need to sort them based on the frequencies.</p>
  
  <p>To put it simply, the data structure needs to be an <strong>associative array</strong>, that can be sorted <strong>BY VALUES</strong> , I already put the lines into the <code>HashMap</code> and got surprised by the fact <strong>that it can't be sorted</strong> , now I'm stuck thinking about another data structure.</p>
  
  <p>P.S. (using two lists is not suited to my program because it needs to do a lot of calculations, so it would be better if a single structure holds each <code>String</code> and its occurence instead of a list for the <code>String</code>s and annother for the frequency).</p>
  
  <p>EDIT: I appreciate the help, but some people are suggesting a <code>TreeMap</code>, so I want to specify something here: I need the structure sorted by the occurences of the strings (in the case of <code>Map</code>s it would be the values not the keys).</p>