标签:2.4 one cti and ict 排序规则 返回值 iter 方法
sorted(iterable, key=None, reverse=False)
Return a new list containing all items from the iterable in ascending order.
A custom key function can be supplied to customise the sort order, and the
reverse flag can be set to request the result in descending order.
l1 = [1,3,5,-2,-4,-6] l2 = sorted(l1,key=abs) print(l1) print(l2)
列表按照每一个元素的len排序
l = [[1,2],[3,4,5,6],(7,),‘123‘] print(sorted(l,key=len))
标签:2.4 one cti and ict 排序规则 返回值 iter 方法
原文地址:https://www.cnblogs.com/mys6/p/10561402.html