【发布时间】:2020-07-22 10:53:13
【问题描述】:
我正在尝试对这种数组进行排序:
array([[0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0.46938776, 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0.53061224, 0. ,
0. , 0. , 0. , 0. , 0. ]])
我的代码是这样的:
def selection_sort(x):
for i in range(len(x)):
swap = i + np.argmin(x[i:])
(x[i], x[swap]) = (x[swap], x[i])
return x
selection_sort(output)
我也试过用这个:
print(np.sort(arr))
但不幸的是没有工作任何想法?
【问题讨论】: