L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)]
def nameSort(x) : return x[0][0].upper()
def scoreSort(x) : return 100 - x[1] print(sorted(L, key = nameSort)) print(sorted(L, key = scoreSort))
Sign in to make a reply
xinyujaychou
L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)]
def nameSort(x) : return x[0][0].upper()
def scoreSort(x) : return 100 - x[1] print(sorted(L, key = nameSort)) print(sorted(L, key = scoreSort))