faster sort?
Is Array.prototype.sort already max fast?
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 https://github.com/josdejong/mathjs/issues/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 @fast/sort, maybe taking it further to slicing even more the fast project with @fast/array, @fast/object, @fast/string and @fast/function