Sort an array according to the elements of another array

I’ll be surprised if anything is much faster than the obvious way:

a2.sort_by{|x| a1.index x.id}

Leave a Comment