title: How to find the index of a element in a sorted set of documents in mongo db?
body: <p>In mongodb how can I get the position of a element in a sorted list of documents?</p>
  
  <p>E.g: If I have 4 students with scores. I want to sort these documents by score and then get the position of John. Result should be 3 in following example.</p>
  
  <pre><code>Name Score
  Paul  4
  Sam   5
  John  7
  Ron   20
  </code></pre>
  
  <p>I tried to use count but it didn't work with:</p>
  
  <pre><code>User.find({ "name": "john"}).count()
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/10813908/get-position-of-selected-document-in-collection-mongodb">[Get position of selected document in collection [mongoDB] ]</a> This other question doesn't give any answer for this question, its a different question even-though titles are similar.</p>