Recursion-Dictionary Order(smaller) : Test case failing

I just used iterative solution. I know using iterative solution is giving me different order. Thats why used a sort function to get that order. Please check why am I failing…
link : https://ide.geeksforgeeks.org/IoDfq2NPKo

Hi Ayush,
Try this testcase

Input :
cabd

Expected Output :
acbd
acdb
abcd
abdc
adcb
adbc
bcad
bcda
bacd
badc
bdca
bdac

Your Output :
adcb
adbc
acdb
acbd
abdc
abcd
bdca
bdac
bcda
bcad
badc
bacd

I am not getting the logic to get such order. My answer is correct if we ignore the order.
But I dont know how to get such order.

Hi Ayush,
Generate the permutations using recursion as taught in the course. The only change required to generate this particular order is to skip the backtracking step and your code would pass definitely.