I am interested in ordering a collection based on multiple keys, such as sorting by age in descending order and score in ascending order:
db.collection.find().sort( { age: -1, score: 1 } );
While this approach works well, I want to ensure that the age key is always prioritized over the score key.
In JavaScript, the order of object keys may not be guaranteed, as discussed here.
The documentation from MongoDb regarding sorting is somewhat unclear.
Therefore, I'm seeking clarification on whether the method demonstrated is reliable in terms of maintaining the specified order of arguments.
Thank you.