3 ms·
Hey, love it! I know that you know it can handle duplicates, but a simple fix can work here. Make an array called `equal` before making the `less` and `greater
by kbr 10y ago
Hey, love it! I know that you know it can handle duplicates, but a simple fix can work here.
Make an array called `equal` before making the `less` and `greater` arrays.
const equal = arr.filter(i => i === pivot);
Then, instead of adding the pivot, add the equal array.
return [
...quicksort(less),
...equal,
...quicksort(greater)
]