#C13608. Sort Letters and Numbers
Sort Letters and Numbers
Sort Letters and Numbers
Given an alphanumeric string, the task is to separate the letters and digits, sort them individually (all letters in alphabetical order and all digits in ascending order), and then merge them into a single string by concatenating the sorted letters with the sorted digits.
For example, if the input is d3a1c2b4
, after separating and sorting, the letters become abcd
and the digits become 1234
. The final output is abcd1234
.
This problem tests your ability to manipulate strings and sort characters based on their categories.
inputFormat
The input consists of a single line containing a non-empty string s consisting of letters (both uppercase and lowercase are possible) and digits. It is guaranteed that s does not contain any spaces or other special characters.
Input Format (stdin):
string
outputFormat
Output a single string that is the result of concatenating the sorted letters followed by the sorted digits.
Output Format (stdout):
result_string## sample
d3a1c2b4
abcd1234