标签:代码 bar 函数 [1] ret key ted def \n
L = [(‘Bob‘, 75), (‘Adam‘, 92), (‘Bart‘, 66), (‘Lisa‘, 88)]
def by_name(t):
return t[0]
def by_score(t):
return -t[1]
L2 = sorted(L, key=by_name)
print(‘sorted by name :‘ , L2, ‘\n‘)
L3 = sorted(L, key=by_score)
print(‘sorted by score :‘ , L3)
标签:代码 bar 函数 [1] ret key ted def \n
原文地址:https://www.cnblogs.com/zula/p/9804752.html