C100DBA · Question #83
Which is the correct order (lowest to highest) in which MongoDB compares the BSON types?
The correct answer is C. Null, Number, String and Object. Option C is correct because MongoDB's BSON comparison specification places Null lowest, followed by Numbers (integers, longs, doubles, decimals), then Strings (and symbols), and finally Objects - this is the defined sort order used when comparing values of different BSON types in
Question
Which is the correct order (lowest to highest) in which MongoDB compares the BSON types?
Options
- ANumber, Null, String and Object
- BNull, Number, Object and String
- CNull, Number, String and Object
- DString, Null, Number and Object
How the community answered
(22 responses)- C95% (21)
- D5% (1)
Explanation
Option C is correct because MongoDB's BSON comparison specification places Null lowest, followed by Numbers (integers, longs, doubles, decimals), then Strings (and symbols), and finally Objects - this is the defined sort order used when comparing values of different BSON types in queries and aggregations.
Why the distractors are wrong:
- A (Number, Null, String, Object) - Null ranks below Number, not above it.
- B (Null, Number, Object, String) - Strings and Objects are swapped; Strings sort before Objects in MongoDB's BSON order.
- D (String, Null, Number, Object) - String is incorrectly placed first; Null is always the lowest of these four types.
Memory tip: Use the phrase "No Numbers Should Object" → Null → Number → String → Object to lock in the correct lowest-to-highest sequence.
Topics
Community Discussion
No community discussion yet for this question.