#K92062. Sort String by Case and Order
Sort String by Case and Order
Sort String by Case and Order
Given an input string s consisting solely of lower-case and upper-case English letters, your task is to rearrange the letters so that:
- All uppercase letters appear first and are sorted in reverse alphabetical order.
- All lowercase letters follow and are sorted in alphabetical order.
For example, if s = "cBaA"
, then the output should be "BAac"
.
The formal specification is as follows:
Let \( U = \{ x \in s : x \text{ is uppercase} \} \) and \( L = \{ x \in s : x \text{ is lowercase} \} \). Then, output the string formed by concatenating the elements of \( U \) sorted in descending lexicographical order and the elements of \( L \) sorted in ascending lexicographical order.
inputFormat
The input consists of a single line containing the string s
. The string will contain at least 0 and at most 1000 English letters.
Input Format: A single line read from the standard input.
outputFormat
Output the rearranged string according to the problem statement.
Output Format: Print a single line to the standard output.
## samplecBaA
BAac