0

I need help with my code on sorting an string array (manually)

I've already figured it out how to sort it. But my problem is my code only sort the first letter for example Input : cst bat ant cat Output : ant bat cst cat I want it to ouput: ant bat cat cst. https://code.sololearn.com/cEdMShi37ced/?ref=app

23rd Feb 2020, 5:50 PM
Jason Cuerbo
Jason Cuerbo - avatar
6 Answers
23rd Feb 2020, 6:19 PM
Denise Roßberg
Denise Roßberg - avatar
+ 2
The general lesson about bubble sort: https://www.sololearn.com/learn/649/?ref=app Yes, it works also with Strings. instead of > you can use .compareTo()
23rd Feb 2020, 6:29 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Use comparesTo method or use another loop.. And instead of charAt(0), use like charAt(i) but it takes some more changes...
23rd Feb 2020, 5:55 PM
Jayakrishna 🇼🇳
+ 1
Thankk you so much :))
25th Feb 2020, 1:43 AM
Jason Cuerbo
Jason Cuerbo - avatar
0
Thanks :). I will try it.
23rd Feb 2020, 5:58 PM
Jason Cuerbo
Jason Cuerbo - avatar
0
Thank you. Does it work with strings? :)
23rd Feb 2020, 6:21 PM
Jason Cuerbo
Jason Cuerbo - avatar