I have an array of dublicated items like so:
const arr = ['1', '1', '2', '2', '3', '3']
I need to sort it in each other order like so:
const arr = ['1', '2', '3', '1', '2', '3']
How can I solve it by using sort() function?
I tried something like this, but it didn’t work:
const sorted = myDublicatedArray.sort((left, right) => left.index - right.index);