题解 | #成绩排序#
成绩排序
https://www.nowcoder.com/practice/8e400fd9905747e4acc2aeed7240978b
python 还是比较简单,append 添加,sort 对list 排序即可
while True: try: n = int(input()) rever = input() if rever=="0": falg = True elif rever=="1": falg = False else: "typeError" lst = [] for i in range(n): name,socre =input().split() lst.append((name,int(socre))) lst.sort(key = lambda x:x[1],reverse=falg) for i in lst: print(*i) except: break # n = int(input()) # if input()=="0": # falg = True # else: # falg = False # lst = [] # for i in range(n): # name,score = input().split() # lst.append((name,int(score))) # lst.sort(key=lambda x:x[1],reverse=falg) # for i in lst: # print(*i)