Registry / devops / stable-sort

stable-sort

JSON →
library0.1.0jsnpmunverified

Typed stable sorting helpers for JavaScript and TypeScript, version 0.1.0, with zero dependencies. Provides explicit stable sort functions (non-mutating and in-place) with migration-friendly aliases for the deprecated 'stable' package. Ships TypeScript types, requires Node >=18. Differentiator: offers a typed, migration-focused API with helpers like compareBy and reverseComparator, as an independent alternative to the unmaintained 'stable'.

npm install stable-sort
INSTALL
IMPORT
SIG · STABLE-SORT
S
stable-sort
devopsjavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

stableSort
import { stableSort } from 'stable-sort'
const stableSort = require('stable-sort')
Package is ESM-only, no CommonJS export.
compareBy
import { compareBy } from 'stable-sort'
import compareBy from 'stable-sort'
compareBy is a named export, not default.
stable
import { stable } from 'stable-sort'
import { stableSort as stable } from 'stable-sort'
stable is a direct alias for stableSort; avoid double renaming.

Shows typed stable sort with compareBy using a property selector, maintaining stable order for equal ages.

import { stableSort, compareBy } from 'stable-sort'; interface User { name: string; age: number; } const users: User[] = [ { name: 'Alice', age: 30 }, { name: 'Bob', age: 25 }, { name: 'Charlie', age: 30 }, ]; const sorted = stableSort(users, compareBy((u) => u.age)); console.log(sorted); // Bob (25), Alice (30), Charlie (30) — stable order
Debug
Known issues
gotchaPackage requires Node >=18 due to use of modern JavaScript features.
fix
Upgrade Node.js to version 18 or later.
affects: >=0.1.0
deprecatedThe 'stable' package (which stable-sort helps migrate from) is deprecated and no longer maintained.
fix
Replace imports from 'stable' with 'stable-sort' using the migration aliases.
affects: >=0.1.0
breakingstable-sort is ESM-only; attempting to require() it will throw an error.
fix
Use import syntax or switch to dynamic import() if using CommonJS.
affects: >=0.1.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module .../node_modules/stable-sort/index.js from ... not supported.
The package is ESM-only, not compatible with CommonJS require.
fix
Use import syntax: import { stableSort } from 'stable-sort'; or use dynamic import: await import('stable-sort').
SyntaxError: The requested module 'stable-sort' does not provide an export named 'default'
Trying to default import from a package that only has named exports.
fix
Use named imports: import { stableSort, compareBy } from 'stable-sort'.
TypeError: stableSort is not a function
Incorrect import or wrong package name.
fix
Ensure you import stableSort correctly: import { stableSort } from 'stable-sort' (ESM) or const { stableSort } = await import('stable-sort') (dynamic).
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
stable-sort — npm install stable-sort · libregistry