np.sort(a, 1) 对行进行排序
a = np.array([[ 2, 7, 4, 2],
[35, 9, 1, 5],
[22, 12, 3, 2]])
A = np.sort(a,1)
print(A)
>>>
[[ 2 2 4 7]
[ 1 5 9 35]
[ 2 3 12 22]]
np.sort(a, 0) 对列进行排序
a = np.array([[ 2, 7, 4, 2],
[35, 9, 1, 5],
[22, 12, 3, 2]])
A = np.sort(a,0)
print(A)
>>>
[[ 2 7 1 2]
[22 9 3 2]
[35 12 4 5]]
最后
以上就是幽默流沙最近收集整理的关于Python|np.sort(a,dim)|sort对二维数组排序的全部内容,更多相关Python|np内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复