标签:hello aaa res name 返回 abs 排序 ted 返回值
#:sorted排序
"""
sort : 无返回值的
sorted : 有返回值的
"""
# L = [3,1,2,5,6,4]
# L.sort()
# print(L)
# res = sorted(L)
# print(res)
#:加入key关键字 key
# L = [-1,-231,-121223,1,10,2,4]
# L1 = sorted(L,key=abs) #:忽略负数排序
# print(L1)
#:按照长度进行排序
L1 = ["helloAAAAA","names","yangyang","configaa"]
L2 = sorted(L1,key=len)
print(L2)
标签:hello aaa res name 返回 abs 排序 ted 返回值
原文地址:https://www.cnblogs.com/yandh/p/13586553.html