sortedLastIndex
arrayThis method is like sortedIndex except that it returns the highest index at which value should be inserted into array in order to maintain its sort order.
Signature
sortedLastIndex<T>(array: T[], value: T): numberParameters
| Name | Type | Description |
|---|---|---|
array | T[] | The sorted array to inspect |
value | T | The value to evaluate |
Returns
number - Returns the index at which value should be inserted into array
Examples
Find last insertion index
import { sortedLastIndex } from 'dashlite'
const result = sortedLastIndex([4, 5, 5, 5, 6], 5)
console.log(result)Output:
4Available since version 1.0.0