#K50047. Rearrange Sentence

    ID: 28777 Type: Default 1000ms 256MiB

Rearrange Sentence

Rearrange Sentence

Your task is to rearrange the words in a given sentence such that they appear in the lexicographically smallest order. Each word in the sentence is separated by whitespace. If the sentence is empty, output an empty string.

Formally, given a sentence \(S = w_1, w_2, \dots, w_n\), output the sentence \(w_{\pi(1)}\ w_{\pi(2)}\ \dots\ w_{\pi(n)}\) where \(\pi\) is a permutation that sorts the words in lexicographical order.

Note that the ordering is based on standard lexicographical (dictionary) order. For example, the sentence "the quick brown fox jumps over the lazy dog" is rearranged to "brown dog fox jumps lazy over quick the the".

inputFormat

The input consists of a single line containing a sentence. The sentence may be empty or contain several words separated by whitespace.

outputFormat

Output the sentence with its words rearranged in lexicographical order. The words should be separated by a single space.## sample

apple
apple