Recursion dictionary order larger

Failing for 4th test case. I am using sort function since we want output in dictionary order but I think this is creating some problem. please clarify
question:https://hack.codingblocks.com/contests/c/512/361
answer: https://ide.codingblocks.com/s/54453

Hey Tushar, you are not supposed to sort the output, it will result to wrong answer.
for eg.
input:
bca

your code’s output is:
cab
cba

but the expected output is:
cba
cab

https://ide.codingblocks.com/s/55405
The output is not coming for some test cases. Pls help !