+ 4

String Sort question

I was working on this exercise and I came up with this solution: https://code.sololearn.com/c9M9ENIR8ASM I went to go check the solution from the exercise and it was solved without using the Sort method. https://code.sololearn.com/coesHYpS2J42 I was studying the answer to try to better understand it. However, I'm not quite getting it. The lines 28 through about 36, are confusing to me. It seems like the if clause should evaluate to false. I think I am missing something in trying to understand. Can some help?

18th Mar 2018, 7:07 PM
laura
2 odpowiedzi
+ 4
https://code.sololearn.com/cypKjOgIlZ0b Just added additional debug line in the code It takes the first char and compares it with the second char in the string. If the first char is greater than (read comes after the second char in the alphabet) the second char they swop places.
18th Mar 2018, 8:13 PM
sneeze
sneeze - avatar
+ 2
thanks this helps alot!.. I forgot about using debug statements. :)
19th Mar 2018, 1:06 AM
laura