Unless I am missing something, what you want to do is:
>>> a = np.array([90,10,30,40,80,70,20,50,60,0])
>>> np.partition(a, 4)[4]
40
np.partition(a, k)
will place the k
-th smallest element of a
at a[k]
, smaller values in a[:k]
and larger values in a[k+1:]
. The only thing to be aware of is that, because of the 0 indexing, the fifth element is at index 4.