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 a such that, if the corresponding elements in v were inserted before the indices, the order of a would be preserved.

Parameters:
  • a (cupy.ndarray) – Input array. If sorter is None, then it must be sorted in ascending order, otherwise sorter must 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 If right, return the last such index. If there is no suitable index, return either 0 or length of a.

  • sorter – 1-D array_like Optional array of integer indices that sort array a into ascending order. They are typically the result of argsort().

Returns:

Array of insertion points with the same shape as v.

Return type:

cupy.ndarray

Note

When a is not in ascending order, behavior is undefined.