montagejs / collections

This package contains JavaScript implementations of common data structures with idiomatic interfaces.
http://www.collectionsjs.com
Other
2.09k stars 185 forks source link

List.sort ignores supplied comparator. #133

Closed sunrize531 closed 6 years ago

sunrize531 commented 8 years ago

https://github.com/montagejs/collections/blob/master/list.js#L372

Also it probably can be MUCH faster, using node swaps, especially for large collections, since currently it converting data to array and back.

kriskowal commented 8 years ago

Indeed. Since List is far from being an ideal structure for sorting, the current implementation provided is merely provided for completeness. PRs welcome for a less wasteful list sort.

sunrize531 commented 8 years ago

Well, for 'competeness' it must pass its arguments to sorted.

Then, it would be nice to implement something like this: http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html

I'll see what i can do here in next couple of days.

hthetiot commented 6 years ago

see #191