Discuss / Python / 按照姓名排序

按照姓名排序

Topic source

岁益寒

#1 Created at ... [Delete] [Delete and Lock User]

# -*- coding: utf-8 -*-

L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)]

def by_name(t):

    return t[0]

L2=sorted(L,key=by_name)

print(L2)


  • 1

Reply