Compass Basics quiz

If you swap stages, the third ($skip) and second($sort), for example, the result will be different.
In what order should I perform this or that kind of stage, why does the $sort go before $skip?

1 Like

If you have the data:


if you skip 1 and sort you get a, e, f
if you sort and skip you get d, e, f

So what is the correct order for performing such operations ($sort, $skip, $limit and etc)? Is there official documentation on this topic?

It really depends of what you want.

If you want a,e f you do one otherwise you do the other. The is no good order it depends on the requirements.

1 Like

I have different answer compare to the right one.
I was trying to achieve this result with mongoshell:

var pipeline = [
    { $match: { "year": 1991 } },
    { $project: { title: 1 } },
    { $sort: { title: 1 } },
    { $skip: 30 },
    { $limit: 1 }

and with compass itself.
My result is Backdraft. What do I do wrong?

Following up here and closing this thread