+ 1

How i can sort the words in a string by alphabet?

for exampl: you are a programmer: a are programmer you

15th Mar 2018, 12:35 PM
mohamadjavad
mohamadjavad - avatar
5 Answers
+ 6
you could split each word into an array and sort each element by the first letter
15th Mar 2018, 1:05 PM
D_Stark
D_Stark - avatar
+ 6
i dont know python sorry, I could show you in java?
15th Mar 2018, 1:47 PM
D_Stark
D_Stark - avatar
+ 5
Try this: >>> s = "you are a programmer" >>> print(' '.join(sorted(s.split(' ')))) a are programmer you
16th Mar 2018, 1:06 AM
ʒred
ʒred - avatar
+ 1
could u explain more?how can i split each word into an array?
15th Mar 2018, 1:22 PM
mohamadjavad
mohamadjavad - avatar
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
15th Mar 2018, 8:55 PM
Markus Kaleton
Markus Kaleton - avatar