nerdexam
MongoDB

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

MongoDB Fundamentals

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)
  • C
    95% (21)
  • D
    5% (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

#BSON#type comparison#sort order

Community Discussion

No community discussion yet for this question.

Full C100DBA Practice