题解 | #成绩排序#

成绩排序

https://www.nowcoder.com/practice/8e400fd9905747e4acc2aeed7240978b

import sys
num1 = int(input().strip())
just1 = input().strip()
table1 = []
for line in sys.stdin:
    a = line.strip().split(" ")
    table1.append([a[0],int(a[1])])
if just1 == '1':
    resualt1 = sorted(table1,key=lambda x:x[1])
elif just1 == '0':
    resualt1 = sorted(table1,key=lambda x:x[1],reverse=True)
for i in resualt1:
    print(i[0],i[1])

全部评论

相关推荐

勇敢的90后想交流:我愿意付费上班,楼主你就安心字节待着吧,我是真的喜欢上班
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务