排序:数组
x=np.array([2,5,6,2,3,5])dom
np.sort(x) 不改变原数组排序
x.sort() 改变原数组索引
i=np.argsort(x) 返回排序好的索引值it
x[i] 使用花哨索引返回排序好的数组io
x=np.random.randint(0,10,(4,6))sort
np.sort(x,axis=0) 对每一列排序di
np.sort(x,axis=1) 对每一行排序 会丢失原先行或列之间的关系
部分排序:
x=np.array([7,2,3,1,6,5,4])
np.partition(x,3)
结果左边第3小及更小的值 按顺序排列,右边则是任意顺序的其余值
np.partitions(x,2,axis=1) 找出每行的第三小之前的值