Complex query with two $OrderBy
问题 Here's the structure part of my collection : by: [ { id: ObjectId("XX"), type: NumberInt(1) } ], timestamp: NumberInt(), // is timestamp 1 status: NumberInt(0), mails: [ { id: ObjectId("YY"), text: "", timestamp: NumberInt(), // is timestamp 2 } ] I can recover my data in chronological order according to the timestamp 1 via the following lines: ... bson_init(&query); bson_append_document_begin(&query, "$orderby", -1, &child); bson_append_int32(&child, "timestamp", -1, 1); bson_append_document