Home > @rushstack/node-core-library > LegacyAdapters > sortStable
LegacyAdapters.sortStable() method
Warning: This API is now obsolete.
Use native Array.sort(), since Node < 14 is no longer supported
Prior to Node 11.x, the Array.sort()
algorithm is not guaranteed to be stable. If you need a stable sort, you can use sortStable()
as a workaround.
Signature:
static sortStable<T>(array: T[], compare?: (a: T, b: T) => number): void;
Parameters
Parameter | Type | Description |
---|---|---|
array | T[] | |
compare | (a: T, b: T) => number | (Optional) |
Returns:
void
Remarks
On NodeJS 11.x and later, this method simply calls the native Array.sort()
.