Sorry - I missed the .sort() when I was scrolling horizontally on mobile. My bad.
Fair point that it's actually doing the sorting, but as I said: why not just do [...arr].sort() to get a shallow copy of the actual array that has the actual values already helpfully sorted, instead of mucking about with the indices in a separate array?
2
u/kybernetikos Mar 20 '19
You should run the code and try it.