# @writetome51/get-in-numeric-order

> Function takes an array of numbers and returns new array with numbers in numeric order

Latest version **2.0.6** (published 2020-08-21) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @writetome51/get-in-numeric-order
pnpm add @writetome51/get-in-numeric-order
yarn add @writetome51/get-in-numeric-order
bun add @writetome51/get-in-numeric-order
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.6 |
| Published | 2020-08-21 |
| First published | 2019-03-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Steve Thompson |
| Maintainers | writetome51 |
| Keywords | numbers, array, fast, sort, sorting, ascending, order, numeric, function |

## Links

- npm: https://www.npmjs.com/package/@writetome51/get-in-numeric-order
- Repository: https://github.com/writetome51/get-in-numeric-order
- Homepage: https://github.com/writetome51/get-in-numeric-order#readme
- Issues: https://github.com/writetome51/get-in-numeric-order/issues
- npm.io page: https://npm.io/package/@writetome51/get-in-numeric-order

## Dependencies (2)

- [timsort](https://npm.io/package/timsort.md) ^0.3.0
- [@writetome51/get-array-copy](https://npm.io/package/@writetome51/get-array-copy.md) ^1.0.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 2.0.6 (latest) — 2020-08-21
- 2.0.5 — 2020-08-19
- 2.0.4 — 2020-08-19
- 2.0.3 — 2020-08-17
- 2.0.2 — 2020-08-12
- 2.0.1 — 2020-08-12
- 2.0.0 — 2020-08-03
- 1.0.1 — 2019-04-12
- 1.0.0 — 2019-03-21

## README

# getInNumericOrder(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arr: Array&lt;T&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getValueToSortBy? = (element) => element<br>): Array&lt;T&gt;

Returns new copy of `arr` in ascending numeric order. Uses super-fast [node-timsort](https://github.com/mziccard/node-timsort)   
for the actual sorting.  
It sorts using this comparison function: `(a, b) => getValueToSortBy(a) - getValueToSortBy(b)`.  
Optional callback `getValueToSortBy(element)` must return a number. By default it simply  
returns the passed `element`.  


## Examples
```js
// A basic number sort:
let numbers = [10, 6, 44, 2, 21, 66, 32, 44];  
getInNumericOrder(numbers);  
// --> [ 2, 6, 10, 21, 32, 44, 44, 66 ]

// sort objects by property 'age'
let objects = [{age: 12}, {age: 7}, {age: 18}, {age: 5}]; 
getInNumericOrder(objects, (obj) => obj.age);  
// --> [{age: 5}, {age: 7}, {age: 12}, {age: 18}]

// sort arrays by length:
let arrays = [ [1,2,3], [1], [], [4,5], [0], [6,7], [4,5,6] ];
getInNumericOrder(arrays, (arr) => arr.length);  
// --> [ [], [1], [0], [4,5], [6,7], [1,2,3], [4,5,6] ]
```

## Installation
`npm i  @writetome51/get-in-numeric-order`

## Loading
```js
import {getInNumericOrder} from '@writetome51/get-in-numeric-order'; 
```

---
_Source: https://npm.io/package/@writetome51/get-in-numeric-order · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
