np return the top_n rows of a 2-D matrix in descending order of their sum of entries code example
Example 1: np argmin top n
idx = (-arr).argsort()[:n]
Example 2: np argmin top n
# For a 2D array
indices = np.argpartition(arr, -N, axis=1)[:, -N:]