How does Mongo handle a tie when sorting?
I have a number of documents where the timestamp happens to be 开发者_C百科the same, as a result of less than stellar process of creating test data.
When sorting by the timestamp (desc), what other factor does Mongo take into account to sort?
I do not think Mongo internally tries to solve a tie on a sort.
That said, to be on the safe side, you can pass a 2nd sort argument to the sort()
function, for example, if I have comments
sorted by created
date (desc) and further by the text of the comment as comment
.
db.comments.find().sort({created:-1,comment:1})
精彩评论