


If any lowercase or uppercase letters remains left after alternate positioning, then append them at the last of the string in sorted order.
If the given string STR = “rDaBfS” then after sorting STR = “aBfDrS”. In the sorted string, lowercase letters a,f,r, and uppercase letters B, D, S are in sorted order and alternate positions.
The first line contains ‘T’, denoting the number of test cases.
The first line of each test contains a string 'STR' containing lowercase and uppercase letters.
For each test case, print a single line containing a single string denoting the sorted string having the lower case or uppercase letters at alternate positions.
The output for each test case will be printed in a separate line.
You don't have to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= |STR| <= 10 ^ 5
Where ‘T’ is the number of test cases and |STR| is the string’s length.
Time limit: 1 sec.
Algorithm