Float16Array.toSorted - Web documentation
method Float16Array.toSorted
Float16Array.toSorted(compareFn?: (
a: number,
b: number,
) => number
): Float16Array

Copies and sorts the array.

Parameters

optional
compareFn: (
a: number,
b: number,
) => number

Function used to determine the order of the elements. It is expected to return a negative value if the first argument is less than the second argument, zero if they're equal, and a positive value otherwise. If omitted, the elements are sorted in ascending order.

const myNums = Float16Array.from([11.25, 2, -22.5, 1]);
myNums.toSorted((a, b) => a - b) // Float16Array(4) [-22.5, 1, 2, 11.5]

Return Type