I want to sort a string starting from the 2nd character to the last character. Currently I am able to sort the string as per my requirement but I want to utilize sort
function in C++ to achieve the same
Sample input:
san test van best
Sample output:
san van test best
My current program
for (int i1 = 0; i1 < n; ++i1) {
for (int j1 = i1 + 1; j1 < n; ++j1) {
temp5 = arr[j1].substr(1, arr[j1].length() - 1);
temp6 = arr[i1].substr(1, arr[i1].length() - 1);
if (temp6.compare(temp5) > temp5.compare(temp6)) {
a = arr[i1];
arr[i1] = arr[j1];
arr[j1] = a;
}
}
}