Question bank › Sorting
Dsa Sorting Easy

Custom Score Sorter

You are assigned to sort a list of student scores based on two criteria: first by the score in descending order, and for students with the same score, by their names in alphabetical order. Each student's information consists of their name and score. Input format: - The first line contains a single integer, n (1 ≤ n ≤ 1000): the number of students. - The next n lines contain a string (the student's name) followed by an integer (the student's score). Output format: - Print the sorted list of students in the specified order, each on a new line. Example: Input: 3 Alice 88 Bob 95 Charlie 88 Output: Bob 95 Alice 88 Charlie 88

Key concepts

sortingtuplescustom sorting

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.