I want to sort an numpy array according to the sum. Something like
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 would like an array: result = np.array([2, 1, 3, 8], [0, 3, 2, 1]]
What is the most clever and fastest way to do that?