# @isaacs/string-locale-compare

> Compare strings with Intl.Collator if available, falling back to String.localeCompare otherwise

Latest version **1.1.0** (published 2021-09-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install @isaacs/string-locale-compare
pnpm add @isaacs/string-locale-compare
yarn add @isaacs/string-locale-compare
bun add @isaacs/string-locale-compare
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-09-28 |
| First published | 2021-09-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Isaac Z. Schlueter |
| Maintainers | isaacs |

## Links

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

## Recent versions

- 1.1.0 (latest) — 2021-09-28
- 1.0.1 — 2021-09-21
- 1.0.0 — 2021-09-21

## README

# @isaacs/string-locale-compare

Compare strings with Intl.Collator if available, falling back to
String.localeCompare otherwise.

This also forces the use of a specific locale, to avoid using the system
locale, which is non-deterministic.

## USAGE

```js
const stringLocaleCompare = require('@isaacs/string-locale-compare')

myArrayOfStrings.sort(stringLocaleCompare('en'))

// can also pass extra options
myArrayOfNumericStrings.sort(stringLocaleCompare('en', { numeric: true }))
```

## API

`stringLocaleCompare(locale, [options])`

Locale is required, must be a valid locale string.

Options is optional.  The following options are supported:

* `sensitivity`
* `numeric`
* `ignorePunctuation`
* `caseFirst`

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