Dsa
Sorting
Hard
Employee Age Sort
You have a list of employees with their names and ages. Your task is to sort the employees by age in ascending order. In case of a tie in ages, sort them by their names in alphabetical order. Each line contains an employee's information formatted as 'name,age'. Output the sorted list of employees in the same format.
Example Input:
Alice,30
Bob,25
Charlie,30
Daniel,22
Eve,28
Example Output:
Daniel,22
Bob,25
Eve,28
Alice,30
Charlie,30
Key concepts
sortingstructurestuples
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