#K40202. Arrange Words by Length
Arrange Words by Length
Arrange Words by Length
Given a sentence containing several words separated by spaces, output a new sentence in which the words are rearranged in ascending order based on their lengths.
If two words have the same length, they should appear in the same order as they appeared in the original sentence.
Note: The input may be an empty string. In that case, the output should also be an empty string.
Example:
Input: "the quick brown fox jumps" Output: "the fox quick brown jumps"
inputFormat
The input is a single line string sentence
containing words separated by one or more spaces. The input is provided via stdin.
outputFormat
Output a new string where the words are ordered by their lengths in ascending order, with words of equal length appearing in their original order. The output should be printed to stdout.
## samplethe quick brown fox jumps
the fox quick brown jumps