100% in java, easy to understand...
class Solution {\n    public String sortString(String s) {\n        int[] count = new int[26];\n        for(char c : s.toCharArray()){\n            count[c - 97
class Solution {\n    public String sortString(String s) {\n        int[] count = new int[26];\n        for(char c : s.toCharArray()){\n            count[c - 97]++;\n        }\n        StringBuilder sb = new StringBuilder();\n        \n        while(s.length() != sb.length()){\n            Solution.addlth(sb, count);\n            Solution.addhtl(sb, count);\n        }\n        return sb.toString();\n        \n    \n    }\n    static void addlth(StringBuilder ss, int[] count){\n        for(int i = 0; i < 26; ++i){\n            if(count[i] > 0){\n                ss.append((char)(i+97));\n                count[i] -= 1;\n            }\n        }\n    }\n    static void addhtl(StringBuilder ss, int[] count){\n        for(int i = 25; i >= 0; --i){\n            if(count[i] > 0){\n                ss.append((char)(i+97));\n                count[i] -= 1;\n            }\n        }\n    }\n}
[]