题解 | #成绩排序#python
成绩排序
https://www.nowcoder.com/practice/3f27a0a5a59643a8abf0140b9a8cf1f7
import functools def compare(a, b): if a[1] > b[1]: return 1 elif a[1] < b[1]: return -1 else: if a[0] > b[0]: return 1 elif a[0] < b[0]: return -1 else: return 0 n = int(input()) alist = [] while n: number, grade = input().split() alist.append((int(number), int(grade))) n -= 1 alist.sort(key=functools.cmp_to_key(compare)) for item in alist: print(item[0], item[1])