# @discoveryjs/natural-compare

> Compare strings in a natural order

Latest version **1.1.0** (published 2022-09-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @discoveryjs/natural-compare
pnpm add @discoveryjs/natural-compare
yarn add @discoveryjs/natural-compare
bun add @discoveryjs/natural-compare
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2022-09-16 |
| First published | 2022-03-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | ^10 \|\| ^12.20.0 \|\| ^14.13.0 \|\| >=15.0.0 |
| Dependencies | 0 |
| Unpacked size | 55.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Roman Dvornov |
| Maintainers | lahmatiy, smelukov, exdis |
| Keywords | string, compare, sorting, natural, order, human |

## Links

- npm: https://www.npmjs.com/package/@discoveryjs/natural-compare
- Repository: https://github.com/discoveryjs/natural-compare
- Homepage: https://github.com/discoveryjs/natural-compare#readme
- Issues: https://github.com/discoveryjs/natural-compare/issues
- npm.io page: https://npm.io/package/@discoveryjs/natural-compare

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2022-09-16
- 1.0.0 — 2022-03-17

## README

[![NPM version](https://img.shields.io/npm/v/@discoveryjs/natural-compare.svg)](https://www.npmjs.com/package/@discoveryjs/natural-compare)
[![Build Status](https://github.com/discoveryjs/natural-compare/actions/workflows/build.yml/badge.svg)](https://github.com/discoveryjs/natural-compare/actions/workflows/build.yml)
[![Coverage Status](https://coveralls.io/repos/github/discoveryjs/natural-compare/badge.svg?branch=main)](https://coveralls.io/github/discoveryjs/natural-compare?branch=main)

# @discoveryjs/natural-compare

Compare strings in a natural order

## Install

```
npm install @discoveryjs/natural-compare
```

## Usage

```js
import { naturalCompare } from '@discoveryjs/natural-compare';

[
    'file10.js',
    'file1.js',
    'file2.js',
    'file12.js',
    'file9.js'
].sort(naturalCompare);
// file1.js
// file2.js
// file9.js
// file10.js
// file12.js

// standart sorting
[
    'file10.js',
    'file1.js',
    'file2.js',
    'file12.js',
    'file9.js'
].sort();
// file1.js
// file10.js
// file12.js
// file2.js
// file9.js
```

In browser:

```html
    <!-- ESM -->
    <script type="module">
        import { natualCompare } from "@discoveryjs/natural-compare/dist/natural-compare.esm.js";

        array.sort(naturalCompare);
    </script>

    <!-- Old way -->
    <script src="@discoveryjs/natural-compare/dist/natural-compare.js"></script>
    <script>
        array.sort(naturalCompare);
    </script>
```

## License

MIT

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