# javascript-natural-sort

> Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license

Latest version **0.7.1** (published 2014-01-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install javascript-natural-sort
pnpm add javascript-natural-sort
yarn add javascript-natural-sort
bun add javascript-natural-sort
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.1 |
| Published | 2014-01-02 |
| First published | 2014-01-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/javascript-natural-sort) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 47 |
| Author | Jim Palmer |
| Maintainers | kylehousley |
| Keywords | natural, sort, javascript, array, sort, sorting |

## Links

- npm: https://www.npmjs.com/package/javascript-natural-sort
- Repository: https://github.com/Bill4Time/javascript-natural-sort
- Issues: https://github.com/Bill4Time/javascript-natural-sort/issues
- npm.io page: https://npm.io/package/javascript-natural-sort

## Recent versions

- 0.7.1 (latest) — 2014-01-02
- 0.7.0 — 2014-01-01

## README

### Simple numerics

```javascript
>>> ['10',9,2,'1','4'].sort(naturalSort)
['1',2,'4',9,'10']
```

### Floats

```javascript
>>> ['10.0401',10.022,10.042,'10.021999'].sort(naturalSort)
['10.021999',10.022,'10.0401',10.042]
```

### Float & decimal notation

```javascript
>>> ['10.04f','10.039F','10.038d','10.037D'].sort(naturalSort)
['10.037D','10.038d','10.039F','10.04f']
```

### Scientific notation

```javascript
>>> ['1.528535047e5','1.528535047e7','1.528535047e3'].sort(naturalSort)
['1.528535047e3','1.528535047e5','1.528535047e7']
```

### IP addresses

```javascript
>>> ['192.168.0.100','192.168.0.1','192.168.1.1'].sort(naturalSort)
['192.168.0.1','192.168.0.100','192.168.1.1']
```

### Filenames

```javascript
>>> ['car.mov','01alpha.sgi','001alpha.sgi','my.string_41299.tif'].sort(naturalSort)
['001alpha.sgi','01alpha.sgi','car.mov','my.string_41299.tif'
```

### Dates

```javascript
>>> ['10/12/2008','10/11/2008','10/11/2007','10/12/2007'].sort(naturalSort)
['10/11/2007', '10/12/2007', '10/11/2008', '10/12/2008']
```

### Money

```javascript
>>> ['$10002.00','$10001.02','$10001.01'].sort(naturalSort)
['$10001.01','$10001.02','$10002.00']
```

### Movie Titles

```javascript
>>> ['1 Title - The Big Lebowski','1 Title - Gattaca','1 Title - Last Picture Show'].sort(naturalSort)
['1 Title - Gattaca','1 Title - Last Picture Show','1 Title - The Big Lebowski']
```

### By default - case-sensitive sorting

```javascript
>>> ['a', 'B'].sort(naturalSort);
['B', 'a']
```

### To enable case-insensitive sorting
```javascript
>>> naturalSort.insensitive = true;
>>> ['a', 'B'].sort(naturalSort);
['a', 'B']
```

---
_Source: https://npm.io/package/javascript-natural-sort · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
