If i have a string is there a built in function to sort the characters or would I have to write my own?
for example:
string word = \"dabc\";
<
You have to include sort function which is in algorithm header file which is a standard template library in c++.
Usage: std::sort(str.begin(), str.end());
#include
#include // this header is required for std::sort to work
int main()
{
std::string s = "dacb";
std::sort(s.begin(), s.end());
std::cout << s << std::endl;
return 0;
}
OUTPUT:
abcd