title: Wrong order during sorting at first by predefined order, and then by natural order using Comparator method thenComparing()
body: <p>I have a simple object class:</p>
  <pre><code>public class Employee {
      String name;
      String secondName;
   // Conctructor, getters &amp; setters
  }
  </code></pre>
  <p>List of employees:</p>
  <pre><code>        List&lt;Employee&gt; employees = new ArrayList&lt;&gt;(Arrays.asList(
                  new Employee(&quot;Jake&quot;,  &quot;Bbb&quot;),
                  new Employee(&quot;Ann&quot;,   &quot;Aaa&quot;),
                  new Employee(&quot;Ivy&quot;,   &quot;Bbb&quot;),
                  new Employee(&quot;Ivy&quot;,   &quot;Aaa&quot;),
                  new Employee(&quot;Jake&quot;,  &quot;Aaa&quot;),
                  new Employee(&quot;Tom&quot;,   &quot;Iii&quot;),
                  new Employee(&quot;Neil&quot;,  &quot;Xxx&quot;),
                  new Employee(&quot;Keith&quot;, &quot;Ooo&quot;),
                  new Employee(&quot;Tom&quot;,   &quot;Rrr&quot;)
          ));
  </code></pre>
  <p>I want to sort them in predefined order of secondNames first and than in natural order of names:</p>
  <pre><code>List&lt;String&gt; definedOrder = Arrays.asList(&quot;Iii&quot;, &quot;Bbb&quot;, &quot;Aaa&quot;);
  </code></pre>
  <p>in such way:</p>
  <pre><code>employees.sort(
          Comparator.comparing((Employee e) -&gt; definedOrder.indexOf(e.getSecondName()))
                  .thenComparing(Employee::getName));
  
  for (Employee em : employees){
       System.out.println(em.getSecondName() + &quot; / &quot; + em.getName());
  }
  </code></pre>
  <p>And I experct to recive the predifined objects in the list first, then the rest objects:</p>
  <pre><code>Iii / Tom
  Bbb / Ivy
  Bbb / Jake
  Aaa / Ann
  Aaa / Ivy
  Aaa / Jake
  Ooo / Keith
  Xxx / Neil
  Rrr / Tom
  </code></pre>
  <p>But I receive objects firstly sorted in the natural order by <em>name</em>s, (using thenComparing() method), and then from predefined comparison by <em>secondName</em>s:</p>
  <pre><code>Ooo / Keith
  Xxx / Neil
  Rrr / Tom
  Iii / Tom
  Bbb / Ivy
  Bbb / Jake
  Aaa / Ann
  Aaa / Ivy
  Aaa / Jake
  </code></pre>