Increasing Decreasing String

给一个string, 让重组这个string, 其中的字符从小到大,再从大到小,直到没有.

class Solution {
    public String sortString(String s) {
        int[] count = new int[26];
        int n = s.length();
        for(int i = 0; i < n; i++) {
            count[s.charAt(i) - 'a'] ++;
        }
        StringBuilder sb = new StringBuilder();
        boolean loop = true;
        
        while(loop) {
            boolean used = false;
            for(int i = 0; i < 26; i++){
                if(count[i] != 0) {
                    sb.append((char)('a' + i));
                    used = true;
                    count[i] --;
                }
            }
            for(int i = 25; i >= 0; i--){
                if(count[i] != 0) {
                    sb.append((char)('a' + i));
                    used = true;
                    count[i] --;
                }
            }
            loop = used;
        }
        return sb.toString();
    }
}