String/Char Sorting Question

I was wondering when sorting, lets say by low to high, how does a string or a character sort know what's low and high? Does it add the ASCII representation of the letter, or is there some other technique?

string list3[] = {"Atlanta", "Denver", "Chicago", "Dallas"};

How does it know what comes first, second, and so on?
Does it add the ASCII representation of the letter,


This.

Each character has a numerical representation. If that number is less than another number, then that letter comes before the other one.

An interesting side-effect is that this gets screwed up with capitalization, since capital letters preceed lowercase letters.

"Food" < "car" because a capital 'F' comes before a lowercase 'c'
Yeah that's weird...I'm sure someone has programmed something that checks for lowercase vs uppercase. And if lowercase then it would have to be > uppercase to sort from high to low.
Topic archived. No new replies allowed.