【列表】


综述

  • 对列表进行排序

对列表进行排序

1 temp = ['1', '3', '4', '5', '2', '6']
2 temp = [1,5,6,4,8,2,3]
3 print(temp)
4 temp.sort()   # 对列表数据进行排序
5 print(temp)

 结果如下

1 [1, 5, 6, 4, 8, 2, 3]
2 [1, 2, 3, 4, 5, 6, 8]