题解 | 成绩排序
成绩排序
https://www.nowcoder.com/practice/8e400fd9905747e4acc2aeed7240978b
n = int(input())
op = int(input())
score_list = []
for i in range(n):
score_list.append(input().split())
if op == 0: # 按要求排序
new_list = sorted(score_list, key=lambda x: int(x[1]), reverse=True)
elif op == 1:
new_list = sorted(score_list, key=lambda x: int(x[1]))
for i in range(n):
print(f'{new_list[i][0]} {int(new_list[i][1])}')