fast-sort
Blazing fast array sorting. ~2x faster than lodash sort. Benchmark results coming soon.
fast-sort is part of js-flock library exported as single module. For source code and bug/issue reporting visit js-flock github page.
Usage
Small wrapper around sort to make sorting more readable and easier to write.
- Undefined and null values are always sorted to bottom of list no matter if ordering is ascending or descending.
- Supports sorting by multiple properties
- Mutates input array in a same way as native Array.prototype.sort().
import sort from 'fast-sort';
sort([1,4,2]).asc();
sort([1,4,2]).desc();
sort(persons).asc((p) => p.firstName.toLowerCase());
sort(persons).desc([
(p) => p.firstName,
(p) => p.lastName,
(p) => p.dob
]);
sort(null).asc();
sort(33).desc();
Including module
import sort from 'fast-sort';
import sort from 'fast-sort/sort.es5';
import sort from 'fast-sort/sort.es5.min';
import sort from 'js-flock/sort';
import sort from 'js-flock/es5/sort';
import sort from 'js-flock/es5/sort.min';