# alphanumeric-sort

> alphanumeric-sort

Latest version **0.0.1** (published 2013-10-29) · BSD-2-Clause license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2013-10-29 |
| First published | 2013-10-29 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Antti Sykäri |
| Maintainers | anttisykari |
| Keywords | alphanumeric, natural, sort |

## Links

- npm: https://www.npmjs.com/package/alphanumeric-sort
- npm.io page: https://npm.io/package/alphanumeric-sort

## Recent versions

- 0.0.1 (latest) — 2013-10-29

## README

# Alphanumeric sort for JavaScript

A usable, portable, algorithm/comparator for sorting things like filenames and
addresses that contain numbers.

## For example

The algorithm will sort the following files in this order:

	file 1.txt
	file 5.txt
	file 39.txt
	file 100.txt

as opposed to this order (which is what the default JavaScript comparator
produces)

	file 1.txt
	file 100.txt
	file 39.txt
	file 5.txt

## Usage

The library provides a comparator that can be fed to `Array.prototype.sort`.

First you do

	> npm install alphanumeric-sort

And then you do

	var compare = require('alphanumeric-sort').compare;

	["file 100.txt", "file 5.txt", "file 39.txt"].sort(compare);
	//=> ["file 5.txt", "file 39.txt", "file 100.txt"]

## Caveats

The implementation is **quick & dirty** - it just prepends "enough" zeroes
before every digit sequence in the string before comparing lexicographically.

The maximum amount of consecutive digits is 20, after that all bets are off.

(Thanks for the idea,
http://www.bennadel.com/blog/2495-User-Friendly-Sort-Of-Alpha-Numeric-Data-In-JavaScript.htm)

It's not probably very fast.  (To be honest, I haven't really tested.)

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