In neither the BSON 1.0 spec nor the MongoDB BSON Types Reference do we document the index sort order of BinData.
We probably should include it in the MongoDB documentation since it is an important implementation detail. The actual sort order is:
- First compare length
- Then compare the one-byte subtype
- Then compare the content byte-by byte