#K73082. Sort Strings by Length

    ID: 33896 Type: Default 1000ms 256MiB

Sort Strings by Length

Sort Strings by Length

You are given a list of strings. Your task is to sort these strings in ascending order based on their lengths.

Input Format: The first line contains an integer nn, representing the number of strings. The following nn lines each contain one string.

Output Format: Output the sorted list of strings, each on its own line.

Note: If two strings have the same length, maintain their original relative order. This stability can be ensured by using a stable sorting algorithm.

inputFormat

The input begins with an integer nn (0n1050 \le n \le 10^5), which indicates how many strings follow. Each of the next nn lines contains a non-empty string.

outputFormat

Print the strings sorted in ascending order by their length. Each string must be printed on a separate line.## sample

6
apple
banana
kiwi
fig
strawberry
date
fig

kiwi date apple banana strawberry

</p>