排序函数
# 多行注释 ctrl + /
# sort() 与 reverse() 前者改变原本列表的顺序 后者使原本列表倒序
# sorted() 临时改变元素顺序 默认正序 给参数 reverse=True 时 反序
# len() 确定列表长度
# [-1] 打印列表最后一个元素 但列表为空时打印[-1]时error
cars = ['bmw', 'audi', 'toyota', 'subaru']
cars.sort() # 元素排序
print(cars)
cars.sort(reverse=True) # 元素反序
print(cars)
cars.reverse()
print(cars)
# sorted() 不改变原有顺序
print(cars)
print(sorted(cars))
print(cars)
cars.sort() # 元素排序
print(cars)
print(sorted(cars, reverse=True))
print(cars)
cars.reverse()
print(cars)
print(len(cars))
print(cars[-1])