Sorting by string length

TypeScript Easy sorting

Task «Sorting by string length»

The input is a number n, followed by n lines. Sort the lines by increasing length. If the lengths are equal, preserve the original order (stable sort). Output the sorted lines, each on a new line.

Input Format

First line: an integer n (1 ≤ n ≤ 1000). Then n lines, each no longer than 100 characters.

Output Format

n lines sorted by ascending length.

Examples

Example 1

INPUT
1 2 3 4 5 3 4 5 6 7
OUTPUT
3 4 5
main.ts