Sign in to follow this  
originaldaemon

String Sorting (Alphebetical)

Recommended Posts

Quote:
Original post by originaldaemon
Im looking for a method to sort strings alphabetically, that takes into account strings with numbers.

Do the strings consist solely of numbers? Do they end with numbers? Are numbers anywhere? Show us an example of 10 strings sorted in the correct order.

Share this post


Link to post
Share on other sites
Quote:
Im looking for a method to sort strings alphabetically, that takes into account strings with numbers. It would be good if you could point me in the direction of a few methods for me to try out.


So you mean something like str1, str2, str9, str11, str12?
This page list some methods in different languages:
http://www.davekoelle.com/alphanum.html
And this page has a method in C. It can also handle numbers in the middle of a string:
http://sourcefrog.net/projects/natsort/

Share this post


Link to post
Share on other sites
Quote:
Original post by bitshifter
Try a search on bubble sorting.
Its not the fastest way,
but is the easiest way.

Using a library sort function is far more easier (and faster) than implementing bubble sort on your own. You just need to write the comparator function or comparator object (depending on the language).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this