Getting WA in DIVGOLD

Describe your issue

link: CodeChef: Practical coding for everyone

Additional info

My algorithm:
consider the sorted string.
take the substring from the first pos where the given string and sorted string differ. Lets call it s2.
Take the first character from s2 and insert before any pos(i) in s2 where s2[i] > s2[0].
Second, take the minimum character in s2 and put it in front.
return originarl sorted part + min( res of those 2 operations).
please tell me where its going wrong.