Dsa
Sorting
Easy
Book Title Sorter
You are given a list of book titles, where each title may have varying lengths and characters. Your task is to sort these titles first by their length (shortest to longest) and then alphabetically. The input will contain an integer N followed by N lines of book titles. The output should display the titles sorted according to the specified criteria.
Input Format:
N
Title1
Title2
...
TitleN
Output Format:
Title1
Title2
...
TitleN
Example:
Input:
3
The Catcher in the Rye
1984
To Kill a Mockingbird
Output:
1984
The Catcher in the Rye
To Kill a Mockingbird
Key concepts
sortingstringslists
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