题解 | 成绩排序

成绩排序

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

all = int(input())

reseond = int(input())
arr = []
for i in range(all):
    temp = input().split()
    arr.append(temp)

if reseond == 0:
	#注意排序进制转int 如果是字符串会默认排序 按照字符串的首字母
    for i in sorted(arr, key=lambda x: int(x[1]), reverse=True):
        print(i[0] + " " + i[1])
else:
    for i in sorted(arr, key=lambda x: int(x[1])):
        print(i[0] + " " + i[1])

全部评论

相关推荐

不愿透露姓名的神秘牛友
今天 11:47
点赞 评论 收藏
分享
晗江雪:其实我只是觉得你们导员说的很好笑
点赞 评论 收藏
分享
点赞 评论 收藏
分享
06-26 10:08
门头沟学院 C++
北京Golang实习,一个月4700,吃住都不报,公司位置在海淀。请问友友怎么看呢?如果要租房的话有什么建议吗
码农索隆:租房肯定是合租了,剩下的钱,差不多够正常吃饭了,看看能不能学到东西吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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