• Advertisement
Sign in to follow this  

String Sorting (Alphebetical)

This topic is 3441 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
I would start by choosing a programming language.

Share this post


Link to post
Share on other sites
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
If you're using Windows XP or later, this is probably what you're after.
It's called StrCmpLogicalW.

[Edited by - iMalc on August 18, 2008 2:53:50 AM]

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
Sign in to follow this  

  • Advertisement