According to Mongo's docs, you can specify multiple sort keys like this:
{ $sort : { age : -1, posts: 1 } }
Which they say will sort first by age (descending) then by posts (ascending).
But the sort query is a Javascript object. To the best of my knowledge, although implementations typically iterate over properties in the order they were created, that's not actually part of ECMAScript's spec: object properties officially have no order.
Is MongoDB really relying on arbitrary behavior that could vary by implementation, am I wrong about the ECMAScript spec, or am I missing something in the Mongo docs that lets you tune the precedence some other way?