#K85652. Descending String Length Sort

    ID: 36689 Type: Default 1000ms 256MiB

Descending String Length Sort

Descending String Length Sort

Given a list of strings, sort them in descending order based on their lengths. If two strings have the same length, maintain their original relative order (i.e. a stable sort). Mathematically, for any two strings \(s_i\) and \(s_j\), if \(|s_i| > |s_j|\) then \(s_i\) should appear before \(s_j\) in the output.

inputFormat

The first line of input contains an integer \(n\), which denotes the number of strings. The following \(n\) lines each contain a single string.

outputFormat

Output \(n\) lines containing the sorted strings. Each string must be printed on a new line in the order determined by the sorting rules.

## sample
4
apple
banana
pear
kiwi
banana

apple pear kiwi

</p>