Lexicographical Sorting R
bool customCompare(const string &a, const string &b) {
if (a.length() != b.length()) {
return a.length() < b.length();
}
return a < b; // if lengths equal, compare lexicographically
}
vector<string> bigSorting(vector<string> unsorted) {
sort(unsorted.begin(), unsorted.end(), customCompare);
for (const string &s : unsorted) {
cout << s << endl;
}
return unsorted;
}