#K40017. Segregate and Sort Characters
Segregate and Sort Characters
Segregate and Sort Characters
You are given a string that contains letters, digits, and special characters. Your task is to segregate the characters into three groups as follows:
- Letters: All alphabetic characters, which must be sorted in alphabetical order.
- Digits: All numeric characters, which must be sorted in ascending order.
- Special Characters: All other characters, which must remain in the same order as they appear in the input.
The final output should be a concatenation of the sorted letters, followed by the sorted digits, and then the special characters in their original order.
Note: If the input string is empty, output an empty string.
Mathematically, if we denote the input string as \( S \), let \( L \) be the set of letters, \( D \) be the set of digits, and \( P \) be the sequence of special characters. Then the answer is:
\[ answer = sort(L) + sort(D) + P \]inputFormat
The input consists of a single line containing a string \( S \) which may include letters, digits, and special characters.
outputFormat
Output the transformed string after segregating and sorting its characters as described above. The result is printed to stdout.
## samplec3b1a2!x@z#4
abcxz1234!@#