oki need to sort a string alphabetically by the method of selection sort.
here's the piece of code i don't quit understand.
i think i understand the for loop. but the while function is confusing me. current is of char type and i guess so is the string 's[i-1]. i thought you couldn't compare char's or strings. unless it was done by ACSII, though i'm not how it all works.Code:void sortString(char* s, int size) { int i, j; char current; for (j = 1; j < size; j++) { current = s[j]; i = j; while (i > 0 && current < s[i-1]) { s[i] = s[i-1]; i--; } s[i] = current; } }