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 >>>
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 >>>
发表评论
暂无评论