In this example we will show how to search the sorted NumPy array and find the first index where elements should be inserted to maintain order in Python.
Source Code
import numpy as np
n = np.array([1, 2, 3, 4, 5, 6, 7])
idx = np.searchsorted(n, 4)
print(idx)
Output:
3