#C11960. Sort Words by Length
Sort Words by Length
Sort Words by Length
Given a list of words, your task is to sort them according to the following rules:
- First, by their length in ascending order.
- If two words have the same length, sort them lexicographically in ascending order.
The input is provided via stdin and the output should be printed to stdout.
Example:
Input: 5 apple pear banana kiwi peach</p>Output: kiwi pear apple peach banana
inputFormat
The first line contains an integer n denoting the number of words. The following n lines each contain a single word.
outputFormat
Output the sorted list of words, with each word on a new line.
## sample5
apple
pear
banana
kiwi
peach
kiwi
pear
apple
peach
banana
</p>