Question bank › Sorting
Dsa Sorting Warm-up

Sort by Last Name

Given a list of names in the format 'FirstName LastName', sort the names alphabetically by last name, and in case of a tie, by first name. Print the sorted list of names, one per line. Example Input: John Doe Jane Smith Alice Johnson Bob Doe Example Output: Alice Johnson John Doe Bob Doe Jane Smith

Key concepts

sortingstringscustom-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.