sorted_last_index()
Determines the highest index at which `value` should be inserted into `array` in order to maintain its sorted order.
Implementation
Args: array: A list of elements that are already sorted. value: The value to be inserted. Returns: The index at which `value` should be inserted to keep the array sorted.
Example
sorted_last_index([1, 2, 2, 3, 4], 2)
Expected output: 3
Source Code
def sorted_last_index(array: List[T], value: T) -> int:
return bisect.bisect_right(array, value) # type: ignore