-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
faster sort? #77
Comments
Not sure, but either way it might be nice to have a fast NOT in-place sort, since it would be faster than slicing then sorting. |
yeah it's definitely worth investigating this. I really hate that sort operates in-place, suspect we can beat it with an immutable implementation. |
Yes, I really hate in-place sorting as well.. Hope you fix something out :) |
I guess question no. 1 is whether or not we want a stable sort (I'd say yes) |
+1 Some sorting algorithms are fast for small arrays whilst others performs way better for large arrays in JavaScript (see the suggestion of @zhak55 in josdejong/mathjs#268). It may be interesting to use a different algorithm when dealing with either a small or a large array. |
node-timsort seems to be worth looking in, perf-wise http://mziccard.me/2015/08/10/node-timsort-fast-sorting-nodejs/ |
Yeah, that one seems promising! |
..although that's almost 1000 lines of code :/ |
https://gist.github.com/Yaffle/62addec7c78052ab72cc - merge sort - "slow", but stable |
You could ship with a tiny build system in the repository which bundles different optimizations (like the somewhat expensive 1k dynamic sorting library mentioned above) so you only get what you need, minimizing size. |
Or, alternatively, you could ship sort in a different module, something like |
Is Array.prototype.sort already max fast?
The text was updated successfully, but these errors were encountered: