title: Mongo DB duplication issue while using sorting with limit and skip in aggregation
body: <p>Facing an issue of duplicate records while fetching record by sorting with skip and limit:</p>
  
  <p><strong>Collection Data:</strong></p>
  
  <pre><code>{ 
      "_id" : ObjectId("594b507c9b9469ec9da6a78b"), 
      "name" : "F", 
      "percentage" : 60.0, 
      "weightedFilter" : 2.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  }
  { 
      "_id" : ObjectId("594b507c9b9469ec9da6a78c"), 
      "name" : "I", 
      "percentage" : 80.0, 
      "weightedFilter" : 0.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  }
  { 
      "_id" : ObjectId("594b507c9b9469ec9da6a78d"), 
      "name" : "J", 
      "percentage" : 80.0, 
      "weightedFilter" : 1.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  }
  { 
      "_id" : ObjectId("594b507c9b9469ec9da6a78e"), 
      "name" : "A", 
      "percentage" : 100.0, 
      "weightedFilter" : 0.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  }
  { 
      "_id" : ObjectId("594b507c9b9469ec9da6a78f"), 
      "name" : "K", 
      "percentage" : 80.0, 
      "weightedFilter" : 1.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  }
  { 
      "_id" : ObjectId("594b507c9b9469ec9da6a790"), 
      "name" : "G", 
      "percentage" : 60.0, 
      "weightedFilter" : 2.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  }
  { 
      "_id" : ObjectId("594b507c9b9469ec9da6a791"), 
      "name" : "H", 
      "percentage" : 80.0, 
      "weightedFilter" : 0.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  }
  { 
      "_id" : ObjectId("594b507c9b9469ec9da6a792"), 
      "name" : "B", 
      "percentage" : 100.0, 
      "weightedFilter" : 0.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  </code></pre>
  
  <h2>    }</h2>
  
  <p><strong>Aggregation Query 1:</strong> </p>
  
  <pre><code>db.testing.aggregate([{$sort : { "like": -1 }},{$skip : 0},{$limit:4}]);
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>{ 
      "_id" : ObjectId("594b507c9b9469ec9da6a78d"), 
      "name" : "J", 
      "percentage" : 80.0, 
      "weightedFilter" : 1.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  }
  { 
      "_id" : ObjectId("594b507c9b9469ec9da6a78b"), 
      "name" : "F", 
      "percentage" : 60.0, 
      "weightedFilter" : 2.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  }
  { 
      "_id" : ObjectId("594b507c9b9469ec9da6a78c"), 
      "name" : "I", 
      "percentage" : 80.0, 
      "weightedFilter" : 0.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  }
  { 
      "_id" : ObjectId("594b507c9b9469ec9da6a78e"), 
      "name" : "A", 
      "percentage" : 100.0, 
      "weightedFilter" : 0.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  }
  </code></pre>
  
  <hr>
  
  <p><strong>Aggregation Query 2:</strong> </p>
  
  <pre><code>db.testing.aggregate([{$sort : { "like": -1 }},{$skip : 4},{$limit:4}]);
  
  { 
      "_id" : ObjectId("594b507c9b9469ec9da6a78b"), 
      "name" : "F", 
      "percentage" : 60.0, 
      "weightedFilter" : 2.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  }
  { 
      "_id" : ObjectId("594b507c9b9469ec9da6a78c"), 
      "name" : "I", 
      "percentage" : 80.0, 
      "weightedFilter" : 0.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  }
  { 
      "_id" : ObjectId("594b507c9b9469ec9da6a78e"), 
      "name" : "A", 
      "percentage" : 100.0, 
      "weightedFilter" : 0.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  }
  { 
      "_id" : ObjectId("594b507c9b9469ec9da6a792"), 
      "name" : "B", 
      "percentage" : 100.0, 
      "weightedFilter" : 0.0, 
      "like" : 1.0, 
      "attraction" : 1.0
  }
  </code></pre>
  
  <p><strong>Conclusion:</strong></p>
  
  <p>When changing skip 0->4, got duplicate record having name <strong>F,I,A</strong> </p>
  
  <p>Not getting why this happen?</p>