#K38942. Organize John's Library

    ID: 26310 Type: Default 1000ms 256MiB

Organize John's Library

Organize John's Library

John has a collection of book titles that he wants to organize. Your task is to sort these titles in a case-insensitive manner. For titles that are identical when converted to lowercase, the title that is lexicographically smaller (according to ASCII ordering) should come first. This means that even though the sort is case-insensitive, if two titles differ only in case, the one with uppercase letters (which have lower ASCII values) will be placed before the lowercase counterpart.

For example, given the titles "alpha" and "ALPHA", the title "ALPHA" will come before "alpha" because 'A' (65) is less than 'a' (97) in ASCII order.

Your program should read from standard input and output the sorted titles to standard output.

inputFormat

The input starts with an integer n, denoting the number of book titles. Each of the following n lines contains one book title. The titles may contain spaces and a mix of uppercase and lowercase letters.

outputFormat

Output the book titles, each on a new line, sorted in case-insensitive order. If two titles are identical in lowercase, the title with the lexicographically smaller original string (according to ASCII order) should come first.## sample

5
The Hobbit
harry potter
Moby Dick
harry potter and the Chamber of Secrets
THE GREAT GATSBY
harry potter

harry potter and the Chamber of Secrets Moby Dick THE GREAT GATSBY The Hobbit

</p>