the set of collections I now get through the mongoose query looks like this:
[{
_id: "123456",
sex: 0
},{
_id: "222222",
sex: 1
},{
_id: "111111",
sex: 1
},{
_id: "333333",
sex: 0
}]
:
[{
_id: "123456",
sex: 0
},{
_id: "333333",
sex: 0
},{
_id: "111111",
sex: 1
},{
_id: "222222",
sex: 1
}]
that is, under the condition that sex is ascending, _ id is ascending again.
use the sort (condition 1, condition 2) statement according to the answer given by the same question (https://codeshelper.com/q/10.), which does not return the result correctly, and the sort () of mongoose cannot be sorted by multiple conditions.
so I would like to ask if there is any way to achieve this effect when querying. Or is there any better algorithm that can be implemented?
Thank you