Unusual String Sort
Submissions: 1608   Accuracy:

36.4%

  Difficulty: Basic   Marks: 1

Babul likes to play with string and he always tries do something new with it. This time he found a very typical way to sort a string. What he did is that he took a string composed of both lowercase and uppercase letters and sorted it in such a manner such that the uppercase and lowercase letter comes in an alternate manner but in sorted way, but Babul has to do some other stuffs also, so he needs your help to complete this job as fast as possible.

Example:

Input: bAwutndekWEdkd

Output: AbEdWddekkntuw

Explanation:
Here we can see that letter ‘A’,’E’,’W’ are sorted as well as letters “b,d,d,d,e,k,k,n,t,u,w” are sorted but both appears alternately in the string as far as possible.


Input:
The first line of input contains an integer T denoting the no of test cases.Then T test cases follow. Each line of test case will contain a string S.

 

Output:
For each test case in a new line print the required output.
 

Constraints:
1<=T<=100
1<=|S|<=1000


Example:
Input:

2
bAwutndekWEdkd
AFBRi

Output:
AbEdWddekkntuw
AiBFR

 

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: Prithwish Dasgupta


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.