Collect from Template was collected from
Modified by zmrenwu's blog

Python: Difference between sorted vs sort

Sorted(list) returns a New List

>>> a = [3,2,1]
>>> b = sorted(a)
>>> a
[3, 2, 1]
>>> b
[1, 2, 3]

list.sort() sorts in-place and no return

>>> a = [3,2,1]
>>> b = a.sort()
>>> a
[1, 2, 3]
>>> b
>>>

发表评论

    暂无评论