# 这个方法会改变a自身
a = [7,5,9,3]
# True为逆序,False为正序
a.sort(reverse = False)
print(a)
a.sort(reverse = True)
print(a)
[3, 5, 7, 9]
[9, 7, 5, 3]
# 用这个方法可以将排序后的列表赋值给其他列表
a = [7,5,9,3]
# reverse为True逆序,reverse为False正序
b = sorted(a,reverse=True)
print(b)
b = sorted(a,reverse=True)
print(b)
# 原列表值不会改变
print(a)
[9, 7, 5, 3]
[9, 7, 5, 3]
[7, 5, 9, 3]
a = [11,23,45,7]
a.reverse()
print(a)
[7, 45, 23, 11]