Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
can we sort the character by selection sort,insertion sort,bubble sort?

Very thanks in advance...
Posted

Yes we can! Any questions?

—SA
 
Share this answer
 
Comments
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
If, by your question you mean can we sort character in a string using your specified methods, the answer is yes we can.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-Jun-11 17:31pm    
Not only in a string; could be any container. (So I voted 4.)
The answer is simple. Will you please see mine?
--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)!
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.
 
Share this answer
 
Comments
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?
Please see my answer though.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



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