array.sort_mapped [method]

array.sort_mapped( array map[, bool reverse ] );

sorts the array by sorting the passed array and applying the index map to the first one, returns the array for chaining

a = [ 5, 6, 7, 8 ];
b = [ 3, 1, 4, 2 ];
a.sort_mapped( b ); // a = [6,8,5,7]