1.reverse列表反转排序,无返回值
x = [1,5,2,3,4]
x.reverse()
输出:[4, 3, 2, 5, 1]
2.sort列表排序,无返回值
正序:
a = [5,7,6,3,4,1,2]
a.sort()
输出:[1, 2, 3, 4, 5, 6, 7]
逆序:
a.sort(
reverse
=
False
)
输出:[7,6,5,4,3,2,1]
3.sorted列表排序,有返回值
a = [5,7,6,3,4,1,2]
b = sorted(a)
输出:
a----[5, 7, 6, 3, 4, 1, 2]
b----[1, 2, 3, 4, 5, 6, 7]