题解 | #成绩排序#

成绩排序

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

num_total = int(input().strip()) sort_type = int(input().strip()) lis_res = [] for i in range(num_total): a_key,b_value = map(str,input().strip().split()) lis_res.append([a_key,int(b_value)])############要考虑到重名的同学 if sort_type == 0: lis_res.sort(key =lambda x:x[1],reverse= True) for x in lis_res: print(x[0],x[1]) if sort_type == 1: lis_res.sort(key =lambda x:x[1]) for x in lis_res: print(x[0],x[1])

全部评论

相关推荐

06-05 19:46
已编辑
武汉大学 后端
点赞 评论 收藏
分享
深夜书店vv:腾讯是这样的,去年很多走廊都加桌子当工区
点赞 评论 收藏
分享
07-08 13:48
门头沟学院 C++
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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