Is there an elegant way to reorder JavaScript array? For example, says I have an array like this:
let array = ['a', 'b', 'c']
Now I want to rearrange this to
['b', 'a', 'a', 'c', 'a']
Is there a built-in higher-order function to do that in JavaScript? Something like
let reordered = array.reorderMagic([1, 0, 0, 2, 0])
Where I could just specify an index array? If not, can you suggest a library that can help me do these kinds of matrix-like manipulations?