package
Sort an array of numbers
npm install num-sortGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
4.0 kB
Includes dependencies.
Sort an array of numbers
npm install num-sortimport {numberSortAscending, numberSortDescending} from 'num-sort';
[9, -3, -Infinity, 24, NaN].sort(numberSortAscending);
//=> [NaN, -Infinity, -3, 9, 24]
[9n, 3n, 24n, -5n].sort(numberSortAscending);
//=> [-5n, 3n, 9n, 24n]
[9, -3, -Infinity, 24, NaN].sort(numberSortDescending);
//=> [24, 9, -3, -Infinity, NaN]
[9n, 3n, 24n, -5n].sort(numberSortDescending);
//=> [24n, 9n, 3n, -5n]Ascending sort comparator.
Supports both number and bigint types.
Descending sort comparator.
Supports both number and bigint types.