sorted(list)和list.sort()排序的区别

>>>
>>> a = [1,5,3,2]
>>> sorted(a)
[1, 2, 3, 5]
>>> a
[1, 5, 3, 2]
>>> a.sort()
>>> a
[1, 2, 3, 5]
>>>
>>>
sorted(list) 和 list.sort()的不同之处:
    使用sorted(list)  将改变list
    使用list.sort()     不会改变list
 
 
原文地址:https://www.cnblogs.com/relax1949/p/8784541.html