Challenge 3: Order a Compound Index Correctly — Possible Solution ==================================================================== db.collection.createIndex({ status: 1, priority: 1, createdAt: 1 }) (The exact direction of priority and createdAt — 1 vs -1 — would depend on which way the query actually sorts/ranges, which wasn't fully specified; the IMPORTANT part being tested here is the ORDER of the three fields, not their individual directions.) WHY THIS WORKS AS AN ANSWER ------------------------------ Following the Equality-Sort-Range rule field by field: 1. status: "active" is an EQUALITY match (an exact value), so it goes FIRST. 2. priority is used for SORTING, so it goes SECOND. 3. createdAt is queried with a RANGE ($gt), so it goes LAST. This ordering isn't arbitrary — it reflects how MongoDB can most efficiently use a compound index: narrowing down by the exact-match field first eliminates the most irrelevant documents immediately, then the sort field lets MongoDB return results already in the right order without a separate in-memory sort step, and the range field applies last since range conditions are less selective than an exact match and don't combine as cleanly with sorting. Placing the range field earlier (e.g. before the sort field) would generally make the index less effective for this specific query shape.