cupy.searchsorted#
- cupy.searchsorted(a, v, side='left', sorter=None)[source]#
Finds indices where elements should be inserted to maintain order.
Find the indices into a sorted array
asuch that, if the corresponding elements invwere inserted before the indices, the order ofawould be preserved.- Parameters:
a (cupy.ndarray) – Input array. If
sorterisNone, then it must be sorted in ascending order, otherwisesortermust be an array of indices that sort it.v (cupy.ndarray) – Values to insert into
a.side – {‘left’, ‘right’} If
left, return the index of the first suitable location found Ifright, return the last such index. If there is no suitable index, return either 0 or length ofa.sorter – 1-D array_like Optional array of integer indices that sort array
ainto ascending order. They are typically the result ofargsort().
- Returns:
Array of insertion points with the same shape as
v.- Return type:
Note
When a is not in ascending order, behavior is undefined.
See also