Hashes in Ruby don’t have any order. There is an OrderedHash class in
Rails which may be worth looking at.
It may be possible to maintain the order if you go right down to the
database specific connection object, below the AR connection layer.
There may be a choice of hash or array based results.