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