The only (effective) solution I can think of is to need a copy of the original array.
import numpy as np a = np.array([[4,9,2],[5,1,3]]) idx = np.argsort(a[1])
So idx is the index of the sorted column.
c = a.copy() for i in range(len(idx)): a[:,i] = c[:,idx[i]]
It should be fast enough, but, of course, takes some memory.
alexurba
source share