#1、数组排序
a = [3,1,4,6]
a.sort()
print(a)
执行结果:
![这里写图片描述](https://i-blog.csdnimg.cn/blog_migrate/0477f807ffa997a87e7b1692cad0a59f.png)
2、多维数组排
a = [['5.1.5.40580', 29], ['5.0.8.14000', 11], ['5.0.8.14999', 59], ['5.1.4.37882', 4]]
a.sort(key=lambda x:x[1],reverse=True)
print(a)
- key=lambda x:x[1]:按照数组索引1列进行排序,无此参数默认以0列进行排序
- reverse=True:倒序,无此参数默认升序
执行结果:
![这里写图片描述](https://i-blog.csdnimg.cn/blog_migrate/528b6fcb109f6336fd8698a2b79097e4.png)