#C4059. Sort String: Letters Before Digits
Sort String: Letters Before Digits
Sort String: Letters Before Digits
You are given a string S which contains both alphabetical characters (letters) and digits. Your task is to rearrange the characters in S such that:
- All the letters appear in ascending order.
- Followed by all the digits in ascending order.
For example, if S = "d3b2a1c4", the output should be "abcd1234"
because the letters sorted are a, b, c, d
and the digits sorted are 1, 2, 3, 4
.
Note: The execution format is via standard input (stdin) and standard output (stdout).
inputFormat
The input consists of a single line containing the string S which includes both letters and digits.
You may assume that S has length at most 105 and contains only alphanumeric characters.
outputFormat
Output a single line --- the rearranged string where all letters (in ascending order) come first and all digits (in ascending order) come next.
## sampled3b2a1c4
abcd1234