Dry run of the recursive part

can you give me a dry run of the recursive part of code
for (int i = 0; i < inp.size(); i++)
{
string ros = inp.substr(0, i) + inp.substr(i + 1);
permute(ros, out + inp[i]);
}

https://ide.codingblocks.com/s/245784 i used the given code but it is showing me wrong test case. please help me out

Hi Divit Goel
Here, The approach is very similar to that of print permutations. After generating all of the permutations all you need to do is compare your ans with the original number and print only when the ans is lexicographically smaller than the original String.
but your code is not printing in lexicographically order. Dry run your code for input string ‘cab’ output should be
abc
acb
bac
bca
but your solution is giving
acb
abc
bac
bca
as output.

how can i sort them lexiographicaly?

https://ide.codingblocks.com/s/246101 i used this code and when i compile i get the desired output but in testcases its showing wrong. please help!