C100DBA CRUD Operations Practice Question
Which cursor method should you use to sort documents by a field named 'age' in descending order?
⚠ Common exam trap
Students frequently confuse the syntax for ascending (1) and descending (-1) order, or attempt to use keywords like 'DESC' which are not part of the MongoDB shell syntax.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
.sort({age: -1})
The sort() method is used to define the order of results returned by a query. Passing {age: -1} ensures that the documents are ordered from oldest to youngest. Mastering sorting is essential for returning data in a meaningful way to users, such as showing the most recent posts or the highest-rated products first, which are common requirements for almost all web and mobile applications.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
.sort({age: 1})
Why it's wrong here
Passing 1 to the sort object specifies ascending order. This would sort documents from youngest to oldest, which is the exact opposite of the requested requirement. It is a common mistake to mix up 1 and -1 when defining sort order in MongoDB queries.
- ✓
.sort({age: -1})
Why this is correct
In MongoDB, -1 represents descending order and 1 represents ascending order. {age: -1} correctly sorts the documents by the 'age' field from highest to lowest. This is the correct way to retrieve documents in reverse chronological or numerical order based on any chosen field.
- ✗
.orderBy({age: 'desc'})
Why it's wrong here
.orderBy() is not a MongoDB method. This syntax is common in some ORMs and SQL-based frameworks but does not exist in the MongoDB shell or standard drivers. Using it will throw an error, as the cursor object does not possess an orderBy function for sorting query results.
- ✗
.order({age: 'desc'})
Why it's wrong here
.order() is also an invalid method in MongoDB. Sorting is exclusively handled by the .sort() cursor modifier. Developers must adhere to the specified syntax of .sort({field: 1/-1}) to correctly organize their data, as using non-existent methods will always result in a runtime failure of the application code.
About these practice questions
One of 222 original C100DBA practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official MongoDB exam blueprint
This C100DBA practice question is part of Courseiva's free MongoDB certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C100DBA exam.