I want to sort a numpy array according to the sum. Sort of
import numpy as np a = np.array([1,2,3,8], [3,0,2,1]) b = np.sum(a, axis = 0) idx = b.argsort()
Now np.take (a, idx) leads to [2, 1, 3, 8].
But I need an array: result = np.array ([2, 1, 3, 8], [0, 3, 2, 1]]
What is the smartest and fastest way to do this?
source share