15,958,175 members
See more:
can we sort the character by selection sort,insertion sort,bubble sort?

Posted

## Solution 3

Yes we can! Any questions?

—SA

Albert Holguin 8-Jun-11 18:22pm
lol, yes the type doesn't matter, but just telling him that characters in C are simply numbers
Sergey Alexandrovich Kryukov 8-Jun-11 18:24pm
Maybe it's useful...
--SA
Keith Barrow 8-Jun-11 18:22pm
Concise and to the point, I like it!
Sergey Alexandrovich Kryukov 8-Jun-11 18:25pm
He he, thank you Keith.
--SA

## Solution 1

If, by your question you mean can we sort character in a string using your specified methods, the answer is yes we can.

Sergey Alexandrovich Kryukov 8-Jun-11 17:31pm
Not only in a string; could be any container. (So I voted 4.)
--SA
Keith Barrow 8-Jun-11 18:30pm
I considered just "Yes", but it was too short, so I had to pad it :(. I also wanted to make the point that sorting "the character" didn't make much sense as a single-item list is inherently sorted (in every possible way??? I'll have to think about this last point)!

## Solution 2

Sure, a character is just an unsigned integer, so you can sort just like any integer... whether the result gets you what you're intending to do, that may be a different question. Not sure for the reason you'd want to sort characters, maybe to place list in alphabetical order?? If so, the case of the letters would be important in the sort process.

Sergey Alexandrovich Kryukov 8-Jun-11 17:33pm
How the type matters? The only required thing is the comparison operation. (I voted 4 this time.) Look at the question -- what answer does it deserve?
--SA

Top Experts
Last 24hrsThis month
 OriginalGriff 30 Pete O'Hanlon 10 Member 13798091 -6 SG Tamilan -20
 Pete O'Hanlon 70 OriginalGriff 60 merano99 20 Member 13798091 10 esteenbrink 10

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900