题解 | 成绩排序

成绩排序

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])

全部评论

相关推荐

03-07 13:32
门头沟学院 C++
未来可欺a:读研吧,这简历只适合学历高的,本科大概率只能干开发,你这个简历开发不匹配,算法和深度学习的话学历又不够
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务