Reorder elements within array by index.
const reorder =let arr = // [6,7,8,9]let arr2 = // [1,1, 2,2, 3,3]
array = reorder(array, index, stride=1)
Shuffle elements in
array according to the
index array passed. Permutes original array.
index array should contain unique indexes. Pass
stride to indicate groups of elements to shuffle.
Originally based on the reference solution, which turns out to be wrong, so algorithm is fully rewritten.