Question bank › Sorting
Dsa Sorting Warm-up

Sort Student Grades

You are given a list of student names and their corresponding grades. Write a program that sorts the students in descending order based on their grades. If two students have the same grade, sort them alphabetically by their names in ascending order. Input: The first line contains an integer N, the number of students. The next N lines each contain a student's name (a string) followed by their grade (an integer). Output: Print the sorted list of students with their grades, one per line, in the format 'Name Grade'. Example: Input: 5 Alice 90 Bob 85 Charlie 90 David 70 Eve 85 Output: Alice 90 Charlie 90 Bob 85 Eve 85 David 70

Key concepts

sortingarraysbasic

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.