Recursion- Dictionary Order smaller

The question demands all the permutations of the string smaller than the given string Printed in Dictionary Order.
For sample input(as in question) cab: o/p given is-
acb
abc
bca
bac
but according to dictionary order output should be:
abc
acb
bac
bca
I am not able to understand how the generated permutations are arranged and printed.I have solved the question by arranging the permutations in alphabetical order.
My code—> https://ide.codingblocks.com/s/63802
My code is failing Test Case 1 and 4.
Suggest what to do…

https://ide.codingblocks.com/s/63810
It is passing all the test cases when i am commenting out the Backtrack case and the sorting operations in the main which i was doing to form the desired result.
Why is it so that on avoiding backtracking my answer is correct? it should not be correct as on avoiding backtracking in case of string permutations the string is changed for subsequent calls while returning…

The question asks for only the permutations of the given string which come before the the given string in the dictionary and doesn’t specify any order. thus there is no need of sorting the answer. The answer which comes from the recursive function is the correct answer.