我有一个像这样的 numpy 数组:
A = array([[-inf, 4, 5, 10, -inf, 1],
[-inf, 2, 6, 8, -inf, 1],
[-inf, 4, -inf, 10, -inf, 100]
])
I need to sort in a decreasing order:
A = array ([ 10,5,4,1,-inf,-inf],
[8,6,2,1,-inf,-inf],
[100,10,4,-inf,-inf,-inf]])
这里的-inf
是float('-inf')
我该怎么做?
我试过这个:
排序(A,key=lambda listA:len(listA),reverse=True)
但是我没有得到排序的数组。有人可以告诉我该怎么做吗?
最佳答案
怎么样
A.sort()
A[:,::-1]
?
引用资料:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.sort.html
http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html
关于python - 反向排序python中的二维numpy数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27054368/