Courseiva
Aggregation Framework →easyMultiple Choice

C100DEV Aggregation Framework Practice Question

Which stage would you use to limit the output of your aggregation to the top 10 most expensive items?

⚠ Common exam trap

Candidates frequently reverse the pipeline order, placing $limit before $sort, which results in arbitrarily truncated documents rather than the true top results.

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 followed by $limit

To achieve this, you must first sort the data by price in descending order using the $sort stage, and then use the $limit stage to capture only the first 10 documents. This is a common pattern in reporting. Getting the order of these stages correct is vital, as limiting before sorting would produce arbitrary results rather than the correct top 10 based on value.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    $limit

    Why it's wrong here

    Using $limit alone is insufficient because it simply cuts off the result set after a specific number of documents without considering their order. If the data is not sorted first, the limit will return the first 10 documents found by the cursor, which may not be the most expensive.

  • ✓

    $sort followed by $limit

    Why this is correct

    This sequence is correct. The $sort stage orders the documents based on the specified criteria, and the subsequent $limit stage constrains the output to the required count. This combination is the standard approach for implementing 'top N' style queries in MongoDB aggregation pipelines, ensuring accuracy in the results.

  • ✗

    $match followed by $limit

    Why it's wrong here

    $match is used for filtering records, not for ordering them by value. Using it before $limit will only restrict the documents based on specific criteria, not by price, so the output will not contain the 'top' items unless the collection was already perfectly sorted by chance.

  • ✗

    $group followed by $limit

    Why it's wrong here

    $group aggregates documents into buckets. If you use it before $limit, you are limiting the number of groups, not individual items. This approach is useful for pagination of grouped results but fails to satisfy the requirement of finding the top 10 individual expensive items across the dataset.

About these practice questions

This C100DEV question is part of Courseiva's 259-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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 C100DEV 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 C100DEV exam.