Get the indices of N highest values in an ndarray
问题 Considering an histogram of shape 100x100x100, I would like to find the 2 highest values a and b, and their indices (a1, a2, a3) and (b1, b2, b3), such as: hist[a1][a2][a3] = a hist[b1][b2][b3] = b We can easily get the highest value with hist.max(), but how can we get the X highest values in a ndarray? I understand that one normally uses np.argmax to retrieve the value indices, but in that case: hist.argmax().shape = () # single value for i in range(3): hist.argmax(i).shape = (100, 100) How