import numpy as np
def practice():
data = np.array([[10,9],[8,7],[6,5],[4,3],[2,1]])
print "Before:"
print data
print
Sort the last column with # argsort () and sort in order
data = data[data[:,-1].argsort()]
print "After:"
print data
if __name__ == '__main__':
practice()
pass
Output:
Before: [[10 9] [ 8 7] [ 6 5] [ 4 3] [ 2 1]]
After: [[ 2 1] [ 4 3] [ 6 5] [ 8 7] [10 9]]
Recommended Posts