I am trying to sort a collection by dateCreated desc but i cant seem to do it.
What i have tried so far:
postOrder.sort({
dateCreated: 'desc'
})
postOrder.sort(dateCreated: 'asc')
any ideas??
Try this:
postOrder.sort{ it.dateCreated } //asc
postOrder.sort{ it.dateCreated }.reverse() //desc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With