String sort in Alphabetical order
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: String sort in Alphabetical order

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,640

    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,640

    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,054

    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.

Tags for this Thread

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center