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.
npm install stable-sortimport { compareBy, stableSort } from "stable-sort";
const sorted = stableSort(users, compareBy((user) => user.lastName));Equal items keep their original relative order.
Returns a new sorted array.
Sorts and returns the same array instance.
Migration alias for stableSort.
Migration alias for sortStableInPlace.
Builds a comparator from a property selector.
Reverses an existing comparator.
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.