题解 | #成绩排序#
成绩排序
https://www.nowcoder.com/practice/8e400fd9905747e4acc2aeed7240978b
person_num = int(input()) flag = int(input()) person_list = [] while person_num > 0: name, score = input().split() person_list.append((name,score)) person_num -= 1 if flag: person_list.sort(key= lambda x : int(x[1])) for name, score in person_list: print(name+" "+score) else: person_list.sort(key= lambda x : int(x[1]),reverse=True) for name, score in person_list: print(name+" "+score)