Return a QuerySet iterating the results of a query in a defined order. Technically an aggregate.
		
		To be successful one must be running MongoDB 3.4 or later. Document order will not be represented otherwise.
		
		Based on the technique described here: http://s.webcore.io/2O3i0N2E3h0r
		See also: https://jira.mongodb.org/browse/SERVER-7528

def find_in_sequence(cls, field, order, *args, **kw):
		"""Return a QuerySet iterating the results of a query in a defined order. Technically an aggregate.
		
		To be successful one must be running MongoDB 3.4 or later. Document order will not be represented otherwise.
		
		Based on the technique described here: http://s.webcore.io/2O3i0N2E3h0r
		See also: https://jira.mongodb.org/browse/SERVER-7528
		"""
		
		field = traverse(cls, field)
		order = list(order)  # We need to coalesce the value to prepare for multiple uses.
		kw['sort'] = {'__order': 1}
		kw.setdefault('projection', {'__order': 0})
		
		cls, collection, stages, options = cls._prepare_aggregate(
				field.any(order),
				{'$addFields': {'__order': {'$indexOfArray': [order, '$' + ~field]}}},
				*args,
				**kw
			)
		
		if __debug__:  # noqa
			# This "foot shot avoidance" check requires a server round-trip, potentially, so we only do this in dev.
			if tuple(collection.database.client.server_info()['versionArray'][:2]) < (3, 4):  # pragma: no cover
				raise RuntimeError("Queryable.find_in_sequence only works against MongoDB server versions 3.4 or newer.")
		
		return collection.aggregate(stages, **options)