第29342题 单选题
现有一个学生信息列表,每个元素为元组(姓名: str, 语文成绩: int, 数学成绩: int),需实现多优先级排序:首先按语文成绩降序排列,语文成绩相同时按数学成绩降序排列。以下Python代码中,属于最简洁且高效的正确实现的是?

以下四个选项均为实现该需求的Python代码,请选择正确且最优的方案:

A
sorted(students, key=lambda x: (x[2], x[1]), reverse=True)
B
sorted(students, key=lambda x: (-x[1], -x[2]))
C
students.sort(key=lambda x: x[2], reverse=True)
students.sort(key=lambda x: x[1], reverse=True)
D
sorted(students, cmp=lambda a, b: b[1]-a[1] or b[2]-a[2])
程序运行统计
暂无判题统计