searchsorted(a, v, side="left", sorter=None)¶
Finds indices where elements should be inserted to maintain order. Finds 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.
side ('left', 'right', optional) – If ‘left’, the index of the first suitable location found is given. If ‘right’, return the last such index. If there is no suitable index, return either 0 or N (where N is the length of a).
Tensor, array of insertion points with the same shape as v.
ValueError – if argument for side or sorter is invalid.
- Supported Platforms:
>>> from mindspore import numpy as np >>> print(np.searchsorted([1,2,3,4,5], 3)) 2 >>> print(np.searchsorted([1,2,3,4,5], 3, side='right')) 3 >>> print(np.searchsorted([1,2,3,4,5], [-10, 10, 2, 3])) [0 5 1 2]