Split the duplicate alphabets into different lists and sort that lists.
For eg.
Input:
"bcdabcehb"
Output:
abcdeh bc b