1.11M Members

alphabetic sorting in C++

 
0
 

I made union of two strings with letters. I need to write function in C++ which sort letters in union.

example

union is "acefd"

I need result "acdef"

Could someone help how to write the function for this in C++?

 
0
 

There are lots of sort algorithms -- google for "bubble sort", which is the easiest one to write. Or you could use cl++ std::sort function.

#include <string>
#include <algorithm>

int main()
{
   std::string s = "acefd";
   std::sort(s.begin(),s.end());
]
 
0
 

I must not use finite function like that you write me,I need to write function step by step which works for alphabetic sorting in C++...

 
0
 

I must not use finite function like that you write me,I need to write function step by step which works for alphabetic sorting in C++...

Ancient Dragon's other suggestion was to do a google search for Bubble Sort - try that and you will get plenty of good links which describe how the algorithm works

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: