How do I order a string by frequency and then by alphabetical order in java?
<p>For practice, I want to order an ASCII string in by frequency and then by alphabetical order in java, so 'banana' should become 'bnnaaa', and 'grammar' should become 'gaammrr'. Here's what I have so far.</p>

<pre><code>public static orderByFrequencyAndThenAlphabet(String str) {
  // 128 ASCII characters possible.
  int[] charCount = new int[128]

  // Get the counts.
  str = str.toCharArray();
  for (char c : str) {
    charCount[int(c)] += 1;
  }

  // Sort by frequency...
}
</code></pre>

<p>As you see, I made a data structure store the counts for each character in the input string. However, how do I now use the data structure to sort the characters by frequency? Should I look into using a priority queue?</p>
