title: Sort list of strings by multiple parameters
body: <p>I'm considering how to sort an ArrayList with two parameters. First by occurences of some char in string, then by natural order. Here is the code:</p>
  
  <pre><code>  ArrayList&lt;String&gt; words;
      words=getWords(sentence);//return all words from sentence
      words.sort(Comparator.comparing(o -&gt; countChar(c,  o))
                       .thenComparing(Comparator::naturalOrder));
  </code></pre>
  
  <p>Method <code>getWords(sentence)</code> return an <code>ArrayList&lt;String&gt;</code> of words from <code>sentence</code>.</p>
  
  <p>Method <code>countChar(c,o)</code> counts number of char <code>c</code> in word <code>o</code>.</p>
  
  <p>When adding <code>.thenComparing(Comparator::naturalOrder))</code> IDE shows that <code>o</code> should be cast to <code>String</code> and that it can't resolve method <code>thenComparing()</code>.</p>
  
  <p>What might be the problem?</p>