Skip to content

bisectLeft

bisectLeft<T, V>(items, value, compare): number

Defined in: ordered/bisect-left.ts:16

Finds the leftmost index in items where value could be inserted while keeping items sorted — before any existing element considered equivalent to it.

O(log n) via binary search. items must already be sorted by compare.

T

V = T

readonly T[]

Array sorted ascending by compare.

V

The value to find an insertion point for.

(item, value) => number

Orders an item against value: negative if the item precedes it, positive if the item follows it, 0 if equivalent.

number

The leftmost valid insertion index, in [0, items.length].