Complete the code to sort the documents by age in ascending order.
db.collection.find().sort({ age: [1] })In MongoDB, sorting in ascending order is done by using 1 as the value for the field in the sort method.
Complete the code to sort the documents by score in descending order.
db.collection.find().sort({ score: [1] })Descending order in MongoDB sort is indicated by -1 for the field.
Fix the error in the code to sort by name in ascending order.
db.collection.find().sort({ name: [1] })The sort method requires 1 for ascending order, not strings or booleans.
Fill both blanks to sort by age ascending and score descending.
db.collection.find().sort({ age: [1], score: [2] })Use 1 for ascending and -1 for descending in MongoDB sort method.
Fill all three blanks to sort by name descending, age ascending, and score descending.
db.collection.find().sort({ name: [1], age: [2], score: [3] })Descending order is -1, ascending is 1. Use these values for each field in the sort method.
