Dsa
Sorting
Warm-up
Sort by Length and Alphabet
You are given a list of words. Sort the words primarily by their length (shortest to longest). If two words have the same length, sort them alphabetically. Print the sorted list of words, one per line.
Example Input:
banana
fig
apple
date
kiwi
Example Output:
fig
date
kiwi
apple
banana
Key concepts
sortingstringslist-manipulation
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