How can i sort a string | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

How can i sort a string

I have one string what is your name... I want this string like is name what your.

2nd Dec 2019, 7:50 AM
Jayashree Kusalkar
7 Answers
+ 3
What language are we talking about? You could split each word by using the split function with the " " (space) value. Then create a new string with the new strings, which should be words.
2nd Dec 2019, 8:05 AM
Fernando Pozzetti
Fernando Pozzetti - avatar
2nd Dec 2019, 8:28 AM
ROHIT KANOJIYA
ROHIT KANOJIYA - avatar
+ 5
Have to tried to get it?
2nd Dec 2019, 7:55 AM
A͢J
A͢J - avatar
0
Yeah I have tried this but each character is sorted... 🅰🅹 - ɪ'ᴍ ᴄʀɪᴍɪɴᴀʟʟʏ ɢᴏᴏᴅ!
2nd Dec 2019, 9:50 AM
Jayashree Kusalkar
0
Split the string with a space into array of words. Then by comparing first (0th) chars of the words sort the words( by swapping..). if you dont get it reply..
2nd Dec 2019, 1:41 PM
Jayakrishna 🇮🇳
0
https://code.sololearn.com/ck3ssTJ27Go6/?ref=app I sorted string like this... If anyone have other solution please share it..
11th Dec 2019, 5:56 AM
Jayashree Kusalkar
0
Jayashree Kusalkar I thought you need only sorting with 1st charecter of words . so i made this code then. Hoping it helps to give idea to another way to split words. look this for split input into array. https://code.sololearn.com/cUsgpFz7xaOe/?ref=app I try to extend it to total words later and post here. edit: https://code.sololearn.com/cx9Ti66w3mwo/?ref=app just i continued to update above code but still it can be improvable by using substring method. if you want that also give a reply...
11th Dec 2019, 9:52 AM
Jayakrishna 🇮🇳