How do sort collections by date or id?

When fetching collections data using the API how do you sort the collection by one of the fields? The documenation just says this without any examples or references as to what json object should be passed: * sort Url encoded sort json type: json

What would you pass to sort the collection by the date in descending order for example?

{_id: 1} // sort by _id asc
{_id: -1} // sort by _id desc

{_id: 1, date:-1} // sort by _id asc + date desc
1 Like