[英]Python numpy sort 1D array
I am trying to sort a numpy array using this very simple code: 我正在尝试使用这个非常简单的代码对numpy数组进行排序:
print np.array([2,0,8,4,1]).sort()
However, I am getting the result: 但是,我得到了结果:
None
Can someone tell me what's going on here? 谁能告诉我这里发生了什么?
The array probably gets sorted in-place, like Python's list.sort()
does so you don't get fooled into thinking the original array is still the same. 数组可能就地排序,就像Python的
list.sort()
一样,所以你不会被认为原始数组仍然是相同的。
arr = np.array([2,0,8,4,1])
arr.sort()
print arr
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.