Skip to content
C

Sort Students by Marks

Easypython

Given a list of (name, marks) pairs, use sorted() with a key and lambda to sort students by marks in descending order.

Approach: read each student as a name and a mark, build a list of tuples, then call sorted(..., key=lambda s: s[1], reverse=True).

Input: First line: the number of students n. Next n lines: name marks, space-separated.

Output: One line: the students sorted by marks descending, printed as a Python list of tuples.

Input (stdin)

Output

Run your code to see output here...