robbiblubber.org

help | login | search:  
>>

read  source  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.



Returns


Returns a result set (cursor).



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