API reference@evolu/commonArray › sortArray

Call Signature

function sortArray<T>(
  array: readonly [T, T],
  compareFn?: (a: T, b: T) => number,
): readonly [T, T];

Defined in: packages/common/src/Array.ts:612

Returns a new sorted readonly array.

Wraps native toSorted. Preserves non-empty type.

Example

sortArray([3, 1, 2], (a, b) => a - b); // [1, 2, 3]

Call Signature

function sortArray<T>(
  array: readonly T[],
  compareFn?: (a: T, b: T) => number,
): readonly T[];

Defined in: packages/common/src/Array.ts:617

Possibly empty array.