Skip to content
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

Open
pakastin opened this issue Dec 3, 2014 · 11 comments
Open

faster sort? #77

pakastin opened this issue Dec 3, 2014 · 11 comments

Comments

@pakastin
Copy link

pakastin commented Dec 3, 2014

Is Array.prototype.sort already max fast?

@bttmly
Copy link
Contributor

bttmly commented Dec 3, 2014

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.

@phpnode
Copy link
Member

phpnode commented Dec 3, 2014

yeah it's definitely worth investigating this. I really hate that sort operates in-place, suspect we can beat it with an immutable implementation.

@pakastin
Copy link
Author

pakastin commented Dec 3, 2014

Yes, I really hate in-place sorting as well.. Hope you fix something out :)

@bttmly
Copy link
Contributor

bttmly commented Dec 4, 2014

I guess question no. 1 is whether or not we want a stable sort (I'd say yes)

@josdejong
Copy link

+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.

@sairion
Copy link

sairion commented Aug 16, 2015

node-timsort seems to be worth looking in, perf-wise http://mziccard.me/2015/08/10/node-timsort-fast-sorting-nodejs/

@pakastin
Copy link
Author

Yeah, that one seems promising!

@pakastin
Copy link
Author

pakastin commented Sep 5, 2015

..although that's almost 1000 lines of code :/

@Yaffle
Copy link

Yaffle commented Jan 27, 2016

https://gist.github.com/Yaffle/62addec7c78052ab72cc - merge sort - "slow", but stable

@wbrickner
Copy link

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.

@munizart
Copy link

munizart commented Dec 6, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants