title: Sorting a list based on multiple fields and each fields can be in different directions
body: <p>Looking for Sorting a List of class Employee</p>
  
  <pre><code>class Employee {
  
  String name;
  int age;
  String dob;    
  }
  </code></pre>
  
  <p>I am looking to sort the list like if the name is equal then age if age is also equal then check dob.
  All these can be in different directions. For example</p>
  
  <p>the name can be ascending order, age can be descending order.</p>
  
  <p>The URL that I am using in my Rest Controller has </p>
  
  <pre><code>orderBy=name,desc&amp;orderBy=age,asc&amp;&amp;orderBy=dob,asc
  </code></pre>
  
  <p>I was looking for Spring Data JPA using Pageable.</p>
  
  <p>But the problem is the Date of Birth in Database is in String.</p>
  
  <p>So I need to convert that to Date.</p>
  
  <p>Then next Option I thought about Ordering in Guava.</p>
  
  <pre><code>Ordering&lt;Employee&gt; orderPrimary = Ordering.natural().onResultOf(new EmployeeOrderByName());
  
  Ordering&lt;Employee&gt; orderSecondary = Ordering.natural().reverse().onResultOf(new EmployeeOrderByAge()); 
  orderPrimary.compound(orderSecondary);
  </code></pre>
  
  <p>But in Url fields can be in a different order and can be in a different direction, here I am not sure how to proceed.</p>
  
  <p>Any best approach to meet my requirement.</p>