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.