0
How to sort words in a sentence in ascending order?
At the input we get the line "This is the first time I've added a sentence in Dutch", at the output we get "a in is the I've This time first Dutch added sentence" https://code.sololearn.com/ciXI8i9uRc0o/?ref=app
6 odpowiedzi
+ 7
This should help:
items = [x for x in (input() or "this is sorting test").split(" ")]
print(items)
print(sorted(items, key = len))
+ 3
What is the sorting key? length of word? or something else?
+ 3
Mary_d9 please clarify your question as it appears abit confusing short of saying
```
x = sorted(["Tom", "Jerry", "Felix", "Stewart Liitle"])
print(x)
```
output
[ Felix , Jerry, Stewart Little, Tom ]
+ 2
Ipang length of word
+ 2
Not clear to me what you are to do, can you provide an example of input and expected output?
+ 1
Mary_d9
If you only want to sort the elements by their length then look at Rik Wittkopp's recommendation 👍
But it is still unclear what you meant by "list with numbers can somehow be connected with list of string". Please elaborate more on that part by adding bit more detail in the Description.
P.S. Are you referring to this newly approved challenge thread?
https://www.sololearn.com/Discuss/2667888/?ref=app