Skip to content

iexitdev/stable-sort

stable-sort

Typed stable sorting helpers for JavaScript and TypeScript.

Modern JavaScript engines already guarantee stable Array#sort, which is why the old stable package is deprecated. This package is for codebases that still want an explicit, typed stable-sort utility, a non-mutating default, and migration-friendly names.

Install

npm install stable-sort

Usage

import { compareBy, stableSort } from "stable-sort";

const sorted = stableSort(users, compareBy((user) => user.lastName));

Equal items keep their original relative order.

API

stableSort(array, compare?)

Returns a new sorted array.

sortStableInPlace(array, compare?)

Sorts and returns the same array instance.

stable(array, compare?)

Migration alias for stableSort.

inplace(array, compare?)

Migration alias for sortStableInPlace.

compareBy(selector, compare?)

Builds a comparator from a property selector.

reverseComparator(compare)

Reverses an existing comparator.

Migration Position

stable-sort is an independent alternative or migration helper for projects moving away from stable. It is not affiliated with the original package maintainers or project.

For release context, see the local migration guide, examples, compatibility notes, source metadata, and adoption plan.

About

Typed stable sorting helpers with migration-friendly aliases for the deprecated stable package.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors