title: Sort a list of lists using comparator
body: <p>I am looking at sorting out a list of lists (on ArrayLists), using a comparator. Where the order is largest first. All sublists will always be of the same size.</p>
  
  <p>For example, a list of </p>
  
  <pre><code>[[4,5,6], [7,9,10], [4,7,8], [1,2,3], [7,9,12]]
  </code></pre>
  
  <p>This should</p>
  
  <pre><code>[[7,9,12], [7,9,10], [4,7,8], [4,5,6], [1,2,3]]
  </code></pre>
  
  <p>I have something like this but only sorts by the first item in each list</p>
  
  <pre><code>List&lt;List&lt;Integer&gt;&gt; list = Arrays.asList(
                  Arrays.asList(4,5,6),
                  Arrays.asList(7,9,10), 
                  Arrays.asList(4,7,8),
                  Arrays.asList(1,2,3), 
                  Arrays.asList(7,9,12));
  
  list.sort((l1, l2) -&gt; l2.get(0).compareTo(l1.get(0)));
  </code></pre>
  
  <p>Which produces:</p>
  
  <pre><code>[[7, 9, 10], [7, 9, 12], [4, 5, 6], [4, 7, 8], [1, 2, 3]]
  </code></pre>
  
  <p>How can I write a comparator, which sorts by the next item in the list if the item before is equal?</p>
  
  <p>For example, [7, 9, 10], [7, 9, 12] should go onto compare the two 7, then the two 9 and then 10 and 12. For example, [4, 5, 6], [4, 7, 8] should go onto compare the two 4, and tthen the 4 and 7 and stop.</p>