Skip to content

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.

License

Notifications You must be signed in to change notification settings

vincenzomaritato/better-num-sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

better-num-sort

License npm

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:

npm install better-num-sort

Usage

Import the library and use the sorting functions:

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 file for details.

About

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.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published