title: How to sort documents in mongoDB?
body: <p>I have a collection like below</p>
  
  <pre><code>{
    _id: ObjectId('1asad23dsa45'),
    name: 'demo',
    addedOn: 1550228980162, // this is timestamp
  },
  {
    _id: ObjectId('12das34fda6'),
    name: 'demo2',
    addedOn: 1550228980156, // this is timestamp
  },
  {
    _id: ObjectId('12asd34fs6dfa'),
    name: 'demo3',
    addedOn: 1550228980160, // this is timestamp
  }
  </code></pre>
  
  <p>I want to update all documents in such as way that all gets sorted by timestamp key</p>
  
  <p>so after update the document may look like this</p>
  
  <pre><code>{
    _id: ObjectId('1asad23dsa45'),
    name: 'demo',
    addedOn: 1550228980162, // this is timestamp
  },
  {
    _id: ObjectId('12asd34fs6dfa'),
    name: 'demo3',
    addedOn: 1550228980160, // this is timestamp
  },
  {
    _id: ObjectId('12das34fda6'),
    name: 'demo2',
    addedOn: 1550228980156, // this is timestamp
  }
  </code></pre>