开发者

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})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜