```python
复制
def sort_students(students, order): if order == 0: sorted_students = sorted(students, key=lambda x: (-x[1], x[0])) else: sorted_students = sorted(students, key=lambda x:x[1], x[0]))
return sorted_students
复制
测试数据
students = [("Alice", 80), ("Bob", 90), ("Charlie", 70), ("David", 90)] order 0 sorted_students = sort_students(students, order) for student in sorted_students: print(student)
输出结果为:
复制
('Bob', 90) ('David', 90) ('Alice', 80) ('Charlie', 70) ```