Sqlalchemy filter by field in list but keep original order?
问题 I have a Shoe model like this: class Shoe(db.Model): id = db.Column(db.Integer, primary_key = True) asin = db.Column(db.String(20), index = True) I have a list of ids like ids = [2,1,3] and when I query on the Shoe model such that the results have ids in the 'ids' list, I want back: [{id:2, asin:"111"},{id:1, asin:"113"},{id:3, asin:"42"}] but the problem is that using the following query statement doesn't preserve the original order, the results will come back random. How do I keep the order