Hi,
I have an array of ids of objects that I want to get from the database, but PostGreSQL returns them sorted by ids:
Users.find([4, 1, 3])
=> [User 1, User 3, User 4]
I know I could sort them back like this:
ids = [4, 3, 1]
r = Users.find(ids)
users = ids.map{|id| r.detect{|each| each.id == id}}
But wouldn't it be better if I could do this with the database? I know MySQL has a "field" option. Does PostGreSQL has something equivalent?
Thank you,
Kevin