Reorder an array with given indexes

We have an array of objects A and an array of indexes B. Reorder objects in array A with given indexes in array B. Do not change array A’s length.

example:

var A = [C, D, E, F, G];
var B = [3, 0, 4, 1, 2];
sort(A, B);
// A is now [D, F, G, C, E];


Share Comments