#K71737. Rearrange Letters and Digits

    ID: 33598 Type: Default 1000ms 256MiB

Rearrange Letters and Digits

Rearrange Letters and Digits

You are given a string s consisting of English letters and digits. Your task is to rearrange the string such that all the letters come first in alphabetical order followed by all the digits in ascending numerical order.

More formally, if the input string is defined as \[ s = s_1s_2\cdots s_n, \] then your goal is to produce a new string \[ \text{result} = L_1L_2\cdots L_kD_1D_2\cdots D_m, \] where:

  • The sequence \(L_1, L_2, \ldots, L_k\) consists of all alphabetic characters in s sorted in increasing lexicographical (alphabetical) order.
  • The sequence \(D_1, D_2, \ldots, D_m\) consists of all digit characters in s sorted in increasing order.

For example, if the input string is "c3b2a1", then after separating and sorting, you'll get "abc" (letters) and "123" (digits), and the output should be "abc123".

inputFormat

The input consists of a single line containing a non-empty string s which consists of English letters and digits.

Input is given from standard input (stdin).

outputFormat

Output the rearranged string such that all letters appear in alphabetical order, followed by all digits in ascending order. The output should be printed to standard output (stdout).

## sample
c3b2a1
abc123