Question bank › Sorting
Dsa Sorting Easy

Student Grade Sorting

You are given a list of students with their names and grades. Your task is to sort these students first by their grades in descending order, and for students with the same grade, by their names in alphabetical order (ascending). Print the sorted list of students. Input: The first line contains an integer N (1 ≤ N ≤ 100) — the number of students. The next N lines each contain a string (name, 1 ≤ len(name) ≤ 100) followed by an integer (grade, 0 ≤ grade ≤ 100). Output: Print the sorted list of students in the format [[name1, grade1], [name2, grade2], ...]. Example: Input: 3 Alice 85 Bob 90 Charlie 85 Output: [[Bob, 90], [Alice, 85], [Charlie, 85]]

Key concepts

sortingtuplescomparisons

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.