nerdexam
MongoDB

C100DBA · Question #19

You are comparing values of different BSON types in mongodb. You want to compare from lowest to highest. Which comparison order is used?

The correct answer is A. MinKey, Null, Numbers,Symbol, String,Object,Array,BinData. Option A correctly reflects MongoDB's official BSON comparison order, where MinKey sits at the absolute bottom as an internal sentinel type, followed by Null, then numeric types (integers, doubles, decimals grouped together), then Symbol and String, then Object, Array, and…

MongoDB Fundamentals

Question

You are comparing values of different BSON types in mongodb. You want to compare from lowest to highest. Which comparison order is used?

Options

  • AMinKey, Null, Numbers,Symbol, String,Object,Array,BinData
  • BMinKey, Null, Numbers,Object,Array,BinData,Symbol, String
  • CObject/Array^inData/Symbol,MinKey, Null, Numbers,String
  • DObjec^Array^inData,Symbol, String,MinKey, Null, Numbers

How the community answered

(47 responses)
  • A
    89% (42)
  • B
    6% (3)
  • C
    2% (1)
  • D
    2% (1)

Explanation

Option A correctly reflects MongoDB's official BSON comparison order, where MinKey sits at the absolute bottom as an internal sentinel type, followed by Null, then numeric types (integers, doubles, decimals grouped together), then Symbol and String, then Object, Array, and finally BinData - this order is documented in the MongoDB specification and governs how mixed-type queries and sorts behave.

Options B, C, and D all misplace key types: B incorrectly moves Object and Array before Symbol/String; C and D both place Object/Array/BinData at the very start, which contradicts the spec where MinKey and Null always anchor the lowest positions.

Memory tip: Use the mnemonic "My Nose Never Smells Something Other Animals Bring" - MinKey, Null, Numbers, Symbol, String, Object, Array, BinData - to recall the ascending order.

Topics

#BSON types#comparison order#type system#MinKey

Community Discussion

No community discussion yet for this question.

Full C100DBA Practice