#K91877. Special Sorting of Words
Special Sorting of Words
Special Sorting of Words
You are given a collection of words. Your task is to sort these words based on their lowercase representation while preserving the original case and the relative order for words that are equivalent in a case-insensitive comparison. In other words, if you denote the lowercase transformation of a word s by \( f(s) = s.lower() \), you must order the words in increasing order of \( f(s) \) using a stable sort.
For example, given the list: "Banana apple orange Grape Apple", the sorted output should be "apple Apple Banana Grape orange".
inputFormat
The input begins with an integer \(n\) on the first line, representing the number of words. The second line contains \(n\) words separated by spaces.
outputFormat
Output a single line containing the sorted words separated by a single space.
## sample5
Banana apple orange Grape Apple
apple Apple Banana Grape orange