import java.util.*;
class Solution {
public String solution(String s) {
String answer = "";
PriorityQueue<String> upper = new PriorityQueue<>(Collections.reverseOrder());
PriorityQueue<String> lower = new PriorityQueue<>(Collections.reverseOrder());
for(int i=0; i<s.length(); i++) {
char c = s.charAt(i);
if(c>='a' && c<='z') { lower.add(String.valueOf(c)); }
else { upper.add(String.valueOf(c)); }
}
while(!lower.isEmpty()) { answer += lower.poll(); }
while(!upper.isEmpty()) { answer += upper.poll(); }
return answer;
}
}