Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Is there any STL function for sorting characters inside a string?

Reply
Thread Tools

Is there any STL function for sorting characters inside a string?

 
 
Lambda
Guest
Posts: n/a
 
      09-04-2007
I'm looking for a STL function to sort characters inside a string,
like:

string_sort("disprove") => "deioprsv".

 
Reply With Quote
 
 
 
 
Barry
Guest
Posts: n/a
 
      09-04-2007
Lambda wrote:
> I'm looking for a STL function to sort characters inside a string,
> like:
>
> string_sort("disprove") => "deioprsv".
>

#include <iostream>
#include <string>
#include <algorithm>

int main()
{
std::string str("disprove");
std::sort(str.begin(), str.end());
std::cout << str << std::endl;
}
 
Reply With Quote
 
 
 
 
Lambda
Guest
Posts: n/a
 
      09-04-2007
On Sep 4, 9:28 am, Barry <(E-Mail Removed)> wrote:
> Lambda wrote:
> > I'm looking for a STL function to sort characters inside a string,
> > like:

>
> > string_sort("disprove") => "deioprsv".

>
> #include <iostream>
> #include <string>
> #include <algorithm>
>
> int main()
> {
> std::string str("disprove");
> std::sort(str.begin(), str.end());
> std::cout << str << std::endl;
>
> }


Thanks. It's so easy, I just find out

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Defining a function inside a function. Whats this feature ? How touse inside a class ? Sur Ruby 4 01-08-2008 02:50 PM
501 PIX "deny any any" "allow any any" Any Anybody? Networking Student Cisco 4 11-16-2006 10:40 PM
Is there any STL like and compatible database library? Tao Wang C++ 2 11-07-2005 12:11 PM
Is there any Matrix in the STL? DeMarcus C++ 8 02-06-2004 08:26 AM
Is there any function in STL to get the equivalence of two sets? Peng Yu C++ 1 07-12-2003 09:07 AM



Advertisments