How do you use the $in query to make mongodb return data in the same order as the input?

  mongodb, question

For example, the order I entered is {id:{$in:[1,4,2,1]}}}. How can mongodb return the corresponding data in this order?

What a strange demand.
Since we know in advance what sort of rules we should follow. Find the data and sort it in the application.