title: Overriding Comparator in Java based on Char frequency not ASCII value
body: <p>I am trying to sort one character array <code>char[] input</code> based on another character's array frequency of each character <code>char[] freq</code></p>
  
  <p>A extremely simple example would be:</p>
  
  <pre><code>input: bey
  freq input: bbbyye
  
  output: after sorted would be "bye"
  </code></pre>
  
  <p>I am iterating over my freq input and putting a key value pair like the following question: char c is key; an int is the value.</p>
  
  <p>Now; how do I sort input based on the frequency? My attempts to implement Comparator have met with failure. My code is now identical to the following <a href="https://stackoverflow.com/questions/21325022/sorting-frequency-of-chars/21325116#21325116">accepted answer</a>.</p>
  
  <p>What I "want" to do is bad java or pseudo-code is:</p>
  
  <pre><code>char[] input;
  Arrays.sort(input, new Comparator&lt;Character&gt;() {
  @Override
  public int compare(Character o1, Character o2) {
    return counts.get(o2) - counts.get(o1); //counts is a static
    //global hashmap with the frequency values
   }
  });
  </code></pre>
  
  <p>I do not expect that to work and it does not the error is The method sort(char[]) in the type Arrays is not applicable for the arguments (char[], new Comparator(){}) </p>