title: weird behaviour mongo aggregation framework
body: <p>I have one Document called account holding and it has below records,</p>
  
  <pre><code>{ "_id" : ObjectId("57cfbb09e4b024be2f1bce57"), 
   "_class" : "com.commercestudio.domain.AccountHolding", 
   "accountId" : "5732933ae4b0b709443b0d1e", 
   "companyId" : "57223d6de4b06c4ef00415b5",
   "brokerageAccountId" : "5KC05007", 
   "symbol" : "AGG", 
   "quantity" : 1.0, 
   "pricePaid" : 112.55, 
   "processDate" : ISODate("2016-09-06T00:00:00.000Z"), 
   "recordDate" : ISODate("2016-09-06T00:00:00.000Z"),
   "createdOn" : ISODate("2016-09-07T07:00:25.479Z") 
  } 
  { "_id" : ObjectId("57cfbb09e4b024be2f1bce5b"), 
    "_class" : "com.commercestudio.domain.AccountHolding", 
    "accountId" : "5732933ae4b0b709443b0d1e",
    "companyId" : "57223d6de4b06c4ef00415b5",
    "brokerageAccountId" : "5KC05007",
    "symbol" : "LQD", 
    "quantity" : 4.0, 
    "pricePaid" : 123.78, 
    "processDate" : ISODate("2016-09-06T00:00:00.000Z"), 
    "recordDate" : ISODate("2016-09-06T00:00:00.000Z"), 
    "createdOn" : ISODate("2016-09-07T07:00:25.498Z") 
  }
  </code></pre>
  
  <p>.....
  now I apply aggrigration framework for finding out latest record date data for perticulat accountId,</p>
  
  <pre><code>db.accountHolding.aggregate( 
    [
    {
      "$match": {
        "accountId": "5834caf32ae7bacc527ef2f3",
        "symbol": {
          "$in": [
            "IUSG",
            "VEA",
            "IEMG",
            "SCHX",
            "VBR",
            "IUSV",
            "VOE"
          ]
        }
      }
    },
    {
      "$group": {
        "_id": "$symbol",
        "recordDate": {
          "$last": "$recordDate"
        },
        "quantity": {
          "$last": "$quantity"
        },
        "pricePaid": {
          "$last": "$pricePaid"
        }
      }
    }
  ])
  </code></pre>
  
  <p>and it returns two different results in two different environments,
  On my development env. it shows,</p>
  
  <pre><code>{ 
      "_id" : "VEA", 
      "recordDate" : ISODate("2018-03-02T00:00:00.000Z"),
      "quantity" : 22.79609, "pricePaid" : 44.14 
  }  
  {  "_id" : "IUSG", 
     "recordDate" : ISODate("2018-03-02T00:00:00.000Z"),
     "quantity" : 8.87831, 
     "pricePaid" : 55.79 
  }
  </code></pre>
  
  <p>something like this and from production env. it shows,</p>
  
  <pre><code>{
      "_id" : "VEA",
      "recordDate" : ISODate("2018-02-26T00:00:00Z"),
      "quantity" : 22.79609,
      "pricePaid" : 45.76
  }
  {
      "_id" : "IUSG",
      "recordDate" : ISODate("2018-02-26T00:00:00Z"),
      "quantity" : 8.87831,
      "pricePaid" : 57.47
  }
  </code></pre>
  
  <p>actually, I am unable to find out the solution why this weird behaviour is taken place, as both env has same data.
  My database server is deployed on AWS instance.</p>
  
  <p>Can someone help me out with finding out the root cause and solution for the same?</p>