Dsa
Sorting
Warm-up
Employee Age Sorter
You are given a list of employees in the format 'name age'. Your task is to sort the employees first by their age in ascending order, and then by their name in alphabetical order if the ages are the same. Print each employee's name and age in the original format on separate lines.
Example Input:
John 28
Alice 34
Bob 28
David 25
Example Output:
David 25
John 28
Bob 28
Alice 34
Key concepts
sortingtuplesbasic programming
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