num-sort
Sort an array of numbers
Last updated a year ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install num-sort 
SYNC missed versions from official npm registry.

num-sort

Sort an array of numbers

Install

npm install num-sort

Usage

import {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]

API

numberSortAscending

Ascending sort comparator.

Supports both number and bigint types.

numberSortDescending

Descending sort comparator.

Supports both number and bigint types.

Related

  • alpha-sort - Alphabetically sort an array of strings

Current Tags

  • 4.0.0                                ...           latest (a year ago)

5 Versions

  • 4.0.0                                ...           a year ago
  • 3.0.0                                ...           6 years ago
  • 2.1.0                                ...           6 years ago
  • 2.0.0                                ...           8 years ago
  • 1.0.0                                ...           11 years ago
Maintainers (1)
Downloads
Total 6
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 6
Dependencies (0)
None
Dev Dependencies (2)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE