#C2886. Reorder String: Digits Before Alphabets
Reorder String: Digits Before Alphabets
Reorder String: Digits Before Alphabets
You are given a string s
consisting of digits and lowercase alphabets. Your task is to rearrange the string so that all the digits appear before any alphabets, while preserving the relative order of the digits as well as the alphabets.
Note: The input string might already be in the required format. If so, simply print it as is.
The solution should read input from standard input (stdin
) and print the result to standard output (stdout
).
For example:
Input: a2b3c1d Output: 231abcd
All formulae are rendered in LaTeX format. For instance, the ordering requirement can be expressed as: \( S = D + L \), where \( D \) represents the sequence of digits and \( L \) the sequence of alphabets.
inputFormat
A single line containing a non-empty string composed of digits and lowercase alphabets. The string will not contain spaces.
outputFormat
A single line containing the rearranged string with all digits appearing before the alphabets while preserving their initial relative order.## sample
a2b3c1d
231abcd