title: How to do stream sort based on multiple comparsions of nested object?
body: <p>Model example:</p>
  
  <p>I need to sort stream of cars based on gender of the driver and then his age.</p>
  
  <pre><code>public class Car {
      String color;
      Driver driver; 
  }
  </code></pre>
  
  <pre><code>public class Driver {
      String name;
      Integer age;
      String gender;  
  }
  </code></pre>
  
  <pre><code>public List&lt;Car&gt; sortCars(List&lt;Car&gt; cars) {
      return cars.stream()
          .sorted(Comparator
                  .comparing(car -&gt; -1 /* car.getDriver().getGender() */ )
                  .thenComparing(car -&gt; -1 /* car.getDriver().getAge() */ ))
          .collect(Collectors.toList());
  }
  </code></pre>
  
  <p>I do not want to create special Comparator classes or implement Comparator interfaces. Is my use case even possible? I've been browsing SO for the past hour and none of the answers work.</p>