title: Spring data mongodb sort on multiple fields
body: <p>I want to sort on multiple fields in MongoDB using Spring data for MongoDB. Currently I am trying to achieve this using aggregation: </p>
  
  <pre><code>    Aggregation agg = newAggregation( 
              match(Criteria.where("userId").is(userId)), 
              sort(Sort.Direction.DESC, "type", "createdDate"), 
      );
      AggregationResults&lt;MyBean&gt; results = mongoOperations.aggregate(agg, MyBean.class, MyBean.class);
  </code></pre>
  
  <p>When I am doing this, it is sorting on the <code>type</code> and <code>createdDate</code> on <code>DESC</code> order. But I want <code>DESC</code> on <code>type</code> and <code>ASC</code> on <code>createdDate</code>.</p>
  
  <p>I tried,</p>
  
  <pre><code>    sort(Sort.Direction.DESC, "type");
      sort(Sort.Direction.ASC, "createdDate");
  </code></pre>
  
  <p>but this is sorting only on <code>createdDate</code>.</p>