CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
+ Reply to Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Jan 2010
    Location
    Netherlands
    Posts
    12

    Question String sort in Alphabetical order

    Hello,

    Does anyone have an algorithm or know a function that can sort a std::string for me?

    Say i have:

    string one = "test";

    sorting it alfabetically would result in > "estt"

    Thanks,

    Neil.

  2. #2
    Join Date
    Feb 2002
    Posts
    4,633

    Re: String sort in Alphabetical order

    Any numerical sort function should work. Each character is just an integer.

    Viggy

  3. #3
    Join Date
    Jan 2010
    Location
    Netherlands
    Posts
    12

    Re: String sort in Alphabetical order

    Do you have some code? I'm lazy

  4. #4
    Join Date
    Feb 2002
    Posts
    4,633

    Re: String sort in Alphabetical order

    Nope. Sorry, I don't work for free.

    Viggy

  5. #5
    Join Date
    Mar 2002
    Location
    Kent, United Kingdom
    Posts
    399

    Re: String sort in Alphabetical order

    Check out std::sort in <algorithm>, it was just a google away

    http://www.cplusplus.com/reference/algorithm/sort/
    your humble savant

  6. #6
    Join Date
    Aug 2005
    Location
    San Diego, CA
    Posts
    1,046

    Lightbulb Re: String sort in Alphabetical order

    If you are one of those people that refuses to use the std algorithms for whatever reason there are many examples of sorting functions on the internet that you can find, copy, and paste. there is no reason for anyone else on this forum to post code when you can find examples in about 30 seconds.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts



HTML5 Development Center

Click Here to Expand Forum to Full Width