robbiblubber.org

help | login | search:  
>>

show wiki  show source  compare to current  compare to previous  read  history 


sort()


MongoDB Driver Function Reference


Sorts the results.
More information can be found in the corresponding entry of the MongoDB Manual.



<cursor>.sort(<sort>)



Arguments


<cursor> The target cursor.
<sort> A BSON document containing the sort fields.



Example


db.employees.find().sort({ age: 1, salary: -1 });


Orders all employees ascending by age, then descending by salary.














home | MongoDB Driver Function Reference | MongoDB Driver