Given np.array([10, 20, 30, 40]), where would 25 be inserted to keep it sorted

NumPy · from Sorting and searching

np.sortnp.argsortnp.argpartitionnp.searchsortednp.argmaxnp.digitize

Putting the kettle on…

Starting up…

Exercise 4

Given np.array([10, 20, 30, 40]), where would 25 be inserted to keep it sorted? Return the position.

your answer
stuck? the lesson behind it
Sorting and searching
argsort is the one that matters — it returns the order, so you can apply it anywhere.