Python基础(sorted)
arr1 = [1,2,3,-30,4,5,-6] arr2 = sorted(arr1)#sorted()函数就可以对list进行排序 arr3 = sorted(arr1,key=abs)#可以接收一个key函数来实现自定义的排序,例如按绝对值大小排序 #print(arr2)#[-30, -6, 1, 2, 3, 4, 5] #print(arr3)#[1, 2, 3, 4, 5, -6, -30] arr4 = ['abc','Cba','bca'] arr5 = sorted(arr4,key=str.lower,reverse=True)#可实现忽略大小写的排序,传入第三个参数reverse=True进行反向排序 #print(arr5) l = [('Bob',75),('Adam',92),('Bart',66),('Lisa',88)] #print(sorted(l))#[('Adam', 92), ('Bart', 66), ('Bob', 75), ('Lisa', 88)] sorted()对上述列表分别按名字排序 def f1(item):#sorted()对上述列表分别按成绩从高到低排序 return item[1] print(sorted(l,key=f1,reverse=True))
https://edu.51cto.com/lecturer/11857712.html 星星课堂web前端系列课程
https://edu.51cto.com/course/25959.html js设计模式课程
https://edu.51cto.com/course/23133.html js进阶与组件化实战课程
https://edu.51cto.com/course/24757.html jquery课程
https://edu.51cto.com/course/22392.html js基础与入门课程
https://edu.51cto.com/course/26063.html vue零基础入门课程
https://edu.51cto.com/course/22393.html xhtml与css基础入门课程