C++ short and easy to understand, 20 lines
\nclass Solution {\npublic:\n    string sortString(string s) {\n        vector<int> counter(26, 0);\n        string ans;\n        \n        for (int i = 0; i < 
```\nclass Solution {\npublic:\n    string sortString(string s) {\n        vector<int> counter(26, 0);\n        string ans;\n        \n        for (int i = 0; i < s.length(); i++)\n            counter[s[i] - \'a\']++;\n\n        while (any_of(counter.begin(), counter.end(), [](int n) { return n > 0; })) {\n            for (int i = 0; i < counter.size(); i++)\n                if(counter[i]-- > 0) \n\t\t\t\t\tans += (i + \'a\');\n\n            for (int i = counter.size() - 1; i >= 0; i--)\n                if (counter[i]-- > 0)\n                    ans += (i + \'a\');\n        }\n        return ans;\n    }\n};\n```
['C', 'C++']