# alphanum-sort

> Alphanumeric sorting algorithm

Latest version **1.1.0** (published 2026-08-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install alphanum-sort
pnpm add alphanum-sort
yarn add alphanum-sort
bun add alphanum-sort
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2026-08-22 |
| First published | 2015-09-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 29 |
| Author | Bogdan Chadkin |
| Maintainers | trysound |
| Keywords | sort, alphanum, alphanumeric, natural, human |

## Links

- npm: https://www.npmjs.com/package/alphanum-sort
- Repository: https://github.com/TrySound/alphanum-sort
- Issues: https://github.com/TrySound/alphanum-sort/issues
- npm.io page: https://npm.io/package/alphanum-sort

## Recent versions

- 1.1.0 (latest) — 2026-08-22
- 1.0.2 — 2015-10-03
- 1.0.1 — 2015-09-27
- 1.0.0 — 2015-09-27

## README

# alphanum-sort

[![CI](https://github.com/TrySound/alphanum-sort/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/TrySound/alphanum-sort/actions/workflows/ci.yml)

Fast, natural-order sorting for strings and numbers.

Unlike lexicographic sorting, `alphanum-sort` compares numeric parts by value, so
`item2` comes before `item10`. It supports mixed values, leading zeros, signs,
and case-insensitive comparisons without modifying the input array.

## Install

```sh
npm install alphanum-sort
```

## Usage

```js
var sort = require('alphanum-sort');

var items = ['item20', 'item19', 'item1', 'item10', 'item2'];
var result = sort(items);

console.log(result);
// ['item1', 'item2', 'item10', 'item19', 'item20']
```

### Case-insensitive sorting

```js
sort(['A', 'C', 'E', 'b', 'd', 'f'], { insensitive: true });
// ['A', 'b', 'C', 'd', 'E', 'f']
```

### Signed numbers

```js
sort(['10', '-1', '5', '-20'], { sign: true });
// ['-20', '-1', '5', '10']
```

## API

### `sort(array[, options])`

Returns a sorted copy of `array`. Values are compared as strings but retain
their original types in the returned array.

#### `options.insensitive`

- Type: `Boolean`
- Default: `false`

Compare values without regard to letter case.

#### `options.sign`

- Type: `Boolean`
- Default: `false`

Treat `+` and `-` immediately before digits as numeric signs.

## Development

```sh
npm install
npm test
```

The test suite supports Node.js 0.10 and newer.

## License

[MIT](LICENSE) © [Bogdan Chadkin](https://github.com/TrySound)

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