This seems like its fairly simple, and should have been asked before, but everything I find on Stack Overflow doesn\'t seem to work. I have an array of 4 objects, and I\'d l
If you have indexes already, then you can just map them to objects:
array = %w[obj1 obj2 obj3 obj4]
desired_order = [2,3,0,1]
desired_order.map{|idx| array[idx]} # => ["obj3", "obj4", "obj1", "obj2"]
desired_order.map{|i| array[i]}
Array#values_at does exactly what you need:
array.values_at(*desired_order)