I have array a that holds the position of what the array b should.
a = [3, 2, 0, 1]
b = ["hello", "hi", 2332, "ben"]
I want to sort b so that it will become
["ben", 2332, "hello", "hi"]
where it get's its index from array a.
Have a look at Array#values_at
b = ["hello", "hi", 2332, "ben"]
a = [3, 2, 0, 1]
p b.values_at(*a) # => ["ben", 2332, "hello", "hi"]