Question bank › Sorting
Dsa Sorting Easy

Sort Employee Salaries

You are given a list of employees, each represented by a tuple containing their name and salary. Write a program that sorts these employees first by salary in ascending order, and if two employees have the same salary, by their names in alphabetical order. The input consists of multiple lines, each line containing an employee's name followed by their salary. Print the sorted list of employee names, one per line. Example input: "Alice 3000\nBob 2500\nCharlie 2500\nDavid 4000" would yield the output: "Bob\nCharlie\nAlice\nDavid".

Key concepts

sortingarraysfunctions

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.