Does MongoDB’s $in clause guarantee order
As noted, the order of the arguments in the array of an $in clause does not reflect the order of how the documents are retrieved. That of course will be the natural order or by the selected index order as shown. If you need to preserve this order, then you basically have two options. So … Read more