How to sort in mongoose?
To sort documents in MongoDB, you need to use sort() method. The method accepts a document containing a list of fields along with their sorting order. To specify sorting order 1 and -1 are used. 1 is used for ascending order while -1 is used for descending order. You can use the below-mentioned code to sort in MongoDB…
Answered Jul 18, 2021 · 1.4K Views Read answer →