DEV Community

Discussion on: Quicksort In Javascript

Collapse
 
faiwer profile image
Stepan Zubashev

... doesn't give you any side-effect, you're right. It's FP pure. But it is copying the whole array every time :) That's where the problem is.

If you truly improve the performance of your sort, you should really focus on choosing better pivots I picked the first for simplicity

I think you may even set pivot equal 0 each iteration and even then it would be faster than version with ... :)

... ruins this algorithm. Most of algorithms have to be impure to be useful.
So you can dramatically improve it by getting rid of excess copies. I think it'd be better even in educational point of view