title: Sorting aggregation addToSet result
body: <p>Is there a way to get result of $addToSet as sorted array ?</p>
  
  <p>I tried to expand the pipeline and $unwind the array, sort it and group it again ,
  but still the result isn't sorted.</p>
  
  <p>The arrays are pretty big and i try to avoid sort them in the the application.</p>
  
  <pre>
  
  Document Example :
  
      {
        "_id" : ObjectId("52a84825cc8391ab188b4567"),
        "id" : 129624
        "message" : "Sample",
        "date" : "12-09-2013,17:34:34",
        "dt" : ISODate("2013-12-09T17:34:34.000Z"),
  
      }
  
  </pre>
  
  <p>Query : </p>
  
  <pre>
  
      db.uEvents.aggregate(
      [
        {$match : {dt : {$gte : new Date(2014,01,01) , $lt : new Date(2015,01,17)}}}
        ,{$sort : {dt : 1}}
        , {$group : {
          _id : {
                  id : "$id"
                  , year : {'$year' : "$dt"}
                  , month : {'$month' : "$dt"}
                  , day : {'$dayOfMonth' : "$dt"}
              }
          ,dt : {$addToSet : "$dt"}
  
        }}    
      ]
  
      );
  
  </pre>