I want to find indices in ascending order of elements in last row in a 2D numpy array. An example is as below.
ti = np.array([[255, 2, 255, 9], [4, 255, 6, 255], [23, 11, 5, 18]])
# output = function(ti[-1])
# output : 2, 1, 3, 0
How do I achieve this? np.argmin only gives one minimum, and I could not find any other way including using partition (which returns sorted elements instead). Kindly help.
I tried np.argsort which sort of gives this output. Others please englighten if any more insights to be added.
np.argsort(ti[-1])
output:
array([2, 1, 3, 0], dtype=int64)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.