+ 1
How i can sort the words in a string by alphabet?
for exampl: you are a programmer: a are programmer you
5 Answers
+ 6
you could split each word into an array and sort each element by the first letter
+ 6
i dont know python sorry, I could show you in java?
+ 5
Try this:
>>> s = "you are a programmer"
>>> print(' '.join(sorted(s.split(' '))))
a are programmer you
+ 1
could u explain more?how can i split each word into an array?
0
make a for loop that adds letters into a variable and if it finds a space it will add the contents of the variable into a list and clears the variable for next word.
After the string iteration is done you can just alphsbetically arrange the list