Man kunne vælge den enkle løsning:
#include <string>
#include <algorithm>
#include <iostream>
int main()
{
std::string s = "godmorgen";
std::cout << "Before: " << s << std::endl;
std::sort(s.begin(), s.end());
std::cout << "After: " << s << std::endl;
}