# better-num-sort

> A powerful JavaScript library for sorting arrays of numbers with enhanced performance and additional features. It supports various number formats, handles special values like NaN and Infinity, and offers customizable sorting options. Easy to integrate and

Latest version **1.0.1** (published 2024-05-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install better-num-sort
pnpm add better-num-sort
yarn add better-num-sort
bun add better-num-sort
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2024-05-19 |
| First published | 2024-05-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=12 |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | SpaceHub Studio |
| Maintainers | vincenzomaritato |
| Keywords | JavaScript, sorting, numbers, array, custom, comparator, NaN, Infinity, performance, sorting, algorithm, ascending, descending, library, open-source, npm, better-num-sort, numeric, sorting, efficient, sorting, data, processing, enhanced, performance, customizable |

## Links

- npm: https://www.npmjs.com/package/better-num-sort
- Repository: https://github.com/openmooncommunity/better-num-sort
- Homepage: https://github.com/openmooncommunity/better-num-sort#readme
- Issues: https://github.com/openmooncommunity/better-num-sort/issues
- npm.io page: https://npm.io/package/better-num-sort

## Alternatives

- [@libsql/sqlite3](https://npm.io/package/@libsql/sqlite3.md) — 39.8K weekly downloads
- [@fortemi/core](https://npm.io/package/@fortemi/core.md) — 461 weekly downloads
- [cdb-converter](https://npm.io/package/cdb-converter.md) — 341 weekly downloads
- [@uplo/adapter-prisma](https://npm.io/package/@uplo/adapter-prisma.md) — 75 weekly downloads
- [typeorm-aios](https://npm.io/package/typeorm-aios.md) — 30 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2024-05-19
- 1.0.0 — 2024-05-19

## README

# better-num-sort

![License](https://img.shields.io/badge/license-MIT-blue.svg)
![npm](https://img.shields.io/npm/v/better-num-sort)

A powerful JavaScript library for sorting arrays of numbers with enhanced performance and additional features. It supports various number formats, handles special values like NaN and Infinity, and offers customizable sorting options. Easy to integrate and use in any project.

## Features

- **Ascending and Descending Sorting**: Sort arrays in both ascending and descending order.
- **Custom Comparator**: Use custom comparator functions for flexible sorting.
- **Special Values Handling**: Properly handles NaN and Infinity values.
- **High Performance**: Optimized for performance with efficient algorithms.

## Installation

Install via npm:

```bash
npm install better-num-sort
```

## Usage

Import the library and use the sorting functions:

```javascript
const { numberSortAscending, numberSortDescending, numberSortCustom } = require('better-num-sort');

// Ascending order
console.log(numberSortAscending([3, 1, 4, 1, 5, 9]));

// Descending order
console.log(numberSortDescending([3, 1, 4, 1, 5, 9]));

// Custom comparator
const customComparator = (a, b) => b - a;
console.log(numberSortCustom([3, 1, 4, 1, 5, 9], customComparator));
```

## API

### `numberSortAscending(array: number[]): number[]`

Sorts an array of numbers in ascending order.

### `numberSortDescending(array: number[]): number[]`

Sorts an array of numbers in descending order.

### `numberSortCustom(array: number[], comparator: (a: number, b: number) => number): number[]`

Sorts an array of numbers using a custom comparator function.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

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