np.sort()函数的作用

np.sort()函数的作用

np.sort()函数的作用是对给定的数组的元素进行排序
a:需要排序的数组
axis:指定按什么排序,默认axis = 1 按行排序, axis = 0 按列排序

1.按行排序

axis = 1 或为默认值,不写这个参数。结果如图:
np.sort()函数的作用
np.sort()函数的作用

2.按列排序

axis = 0
np.sort()函数的作用

3.*才做选择,我都要!!!

先将按行或按列排序得出的数组保存起来,然后在进行一次按行或按列排序。
结果如图:
np.sort()函数的作用