Skip to main content

Home > @jsplumbtoolkit/browser-ui > insertSorted

insertSorted() function

Inserts the given value into the given array at a sorted location.

Signature:

export declare function insertSorted<T>(value: T, array: Array<T>, comparator: (v1: T, v2: T) => number, sortDescending?: boolean): void;

Parameters

ParameterTypeDescription
valueTValue to insert
arrayArray<T>Array to insert into
comparator(v1: T, v2: T) => numberFunction to use when determining sort order.
sortDescendingbooleanDefaults to false; if true, the insertion is sorted in reverse order.

Returns:

void