from operator import itemgetter #按名字排序 L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)] def by_name(t): return t L3 = sorted(L, key=lambda x:x[0]) L2 = sorted(L, key=by_name) print(L3) print(L2) #按学分排序 def by_score(t): return t[1] L3 = sorted(L, key=lambda x:x[1]) L2 = sorted(L, key=by_score) print(L3) print(L2)