isShorter(const string &s1, const string &s2)
{
return s1.size() < s2.size();
}
stable_sort(ret.begin(), ret.end(), isShorter);
either using stable_sort or sort the result is shown in the attachment.
meanwhile:
"By calling stable_sort, we can maintain
alphabetical order among those elements that have the same length:" - C++ Primer 5th edi.
which would mean stable_sort would arrange those string with the same length in alphabetical order, is it?