ActiveRecord中若是想根据自定义的一个数组id集合排序:数组
ids = [2,1,3] users = User.where("id in (?)",ids) results = ids.map{|id| users.detect{|each| each.id == id}}