Question bank › Sorting
Dsa Sorting Easy

Student Grades

You have a list of students with their names and grades. Your task is to sort the students first by their grades in ascending order, and then by their names in alphabetical order for students with the same grade. Input format: - The first line contains an integer n (1 <= n <= 1000), the number of students. - Each of the next n lines contains a string name followed by a float grade (0.0 <= grade <= 100.0). Output format: - Print the sorted student names and grades, each on a new line in the format 'name grade'. Example: Input: 3 Alice 88.5 Bob 92.0 Alice 92.0 Output: Alice 88.5 Alice 92.0 Bob 92.0

Key concepts

sortingliststuples

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 Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.