Any improvements that I can make with this code? Also, is there another way to convert a vector to a string variable without using a for ranged-based loop? From the posts I've seen for converting, I only saw printing the vector instead of returning a string.
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iterator>
using namespace std;
std::string AlphabetSoup(string str) {
std::vector<char>letters;
istringstream iss(str);
copy(istream_iterator<char>(iss),
istream_iterator<char>(),
back_inserter(letters));
std::sort(letters.begin(),letters.end());
//Regrouping the characters into a string
std::string orderedString;
for(auto element : letters)
{
orderedString += element;
}
return orderedString;
}