#C3414. Sorted Letters and Digits

    ID: 46839 Type: Default 1000ms 256MiB

Sorted Letters and Digits

Sorted Letters and Digits

Given a string s consisting of lowercase English letters and digits, your task is to transform the string so that all letters appear in alphabetical order followed by all digits in numerical order.

Formally, if the letters in the string are denoted by letters and the digits by digits, then the output should be:

$output = sorted(letters) + sorted(digits)$

For example, for the input a3c1b2, the output should be abc123.

inputFormat

The input is read from stdin and consists of multiple test cases. The first line contains a positive integer N which indicates the number of test cases. Each of the following N lines contains a non-empty string consisting of lowercase letters and digits.

Example:

4
a3c1b2
b2a1c3
h8e1l4l3o7
5g2a4b1c3

outputFormat

For each test case, output the transformed string on a new line to stdout. The transformation involves sorting all the letters in alphabetical order, followed by sorting all the digits in increasing order.

Example (corresponding to the above input):

abc123
abc123
ehllo13478
abcg12345
## sample
1
a3c1b2
abc123

</p>