Sort by string length

JavaScript Easy sorting

Task «Sort by string length»

Write a function that takes an array of strings and returns it sorted by ascending string length. If the lengths are equal, the original order is preserved (stable sorting). Constraints: the array contains from 1 to 100 strings, each string length from 1 to 100 characters.

Input Format

The first line contains the number n — the number of strings. Then follow n strings, each on a separate line.

Output Format

Output n lines in sorted order, each on a separate line.

Examples

Example 1

INPUT
4 hello world hi bye
OUTPUT
hi bye hello world
main.js