题解 | #HJ68 成绩排序#

成绩排序

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

Python版本

n = int(input())
order_mode = int(input())

status_list = []
for i in range(n):
    name, score = input().strip().split()
    score = int(score)
    status_list.append((i, name, score))

if order_mode == 0:
    key_func = lambda x: (-x[2], x[0])
elif order_mode == 1:
    key_func = lambda x: (x[2], x[0])

status_list.sort(key=key_func)

for status in status_list:
    print(status[1], status[2])
全部评论

相关推荐

昨天 14:11
门头沟学院 Java
点赞 评论 收藏
分享
能干的三文鱼刷了10...:项目和硬件不太相关,很难找到硬件岗的,而且还是女孩子(没有歧视的意思,就是站在企业的角度说)建议往pcb layout工程师或者硬件测试工程师上走
简历中的项目经历要怎么写
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-29 14:02
纠结的茶叶蛋在开会:太简单了,技术和业务没一个够用的,要么学业务,去搞erp或者his,要么专精技术,去搞架构
点赞 评论 收藏
分享
C9本港硕都给我挂了,好歹给个面试啊
丶西瓜:人太多,给他们惯的
投递海尔等公司10个岗位
点赞 评论 收藏
分享
评论
2
1
分享

创作者周榜

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