对列表进行排序操作
1.使用方法sort()对列表进行永久性排序。 例 a=[‘age’,‘slippe’,‘dog’,‘cat’] a.sort() print(a) 输出 [‘age’,‘cat’,dog’,‘slippe’]
2.按与字母顺序相反的顺序排列列表当中的元素。 向sort中传递参数reverse=true 例 a.sort(reverse=true) 输出结果为 [‘slippe’,‘dog’,‘cat’,‘slippe’]
4.使用sorted()对列表进行临时性排序。 例 print(a.sorted()) 输出结果为 [‘age’,‘cat’,‘dog’,‘slippe’] print(a) 输出结果为a 原列表.
5列表中的元素进行倒序输出使用reverse() 方法 6.确定列表的长度使用len()方法。
`