Easy C++ solution
\nclass Solution {\npublic:\n    string sortString(string s) {\n        int count[26]={0};\n        string ans="";\n        // first of all store the frequency 
```\nclass Solution {\npublic:\n    string sortString(string s) {\n        int count[26]={0};\n        string ans="";\n        // first of all store the frequency in the array\n        for(int i=0;i<s.length();i++) {\n            count[s[i]-\'a\']++;\n        }\n        while(true) {\n            bool found=false;\n            // move from \'a\' to \'z\' and append if ith character if present\n            for(int i=0;i<26;i++) {\n                if(count[i]>0) {\n                    found=true;\n                    ans.push_back(\'a\'+i);\n                    count[i]--;\n                }\n            }\n            // if all the characters are used then terminate\n            if(!found) {\n                break;\n            }\n            found=false;\n            // similarly move in the backward direction and append the characters\n            for(int i=25;i>=0;i--) {\n                if(count[i]>0) {\n                    found=true;\n                    ans.push_back(\'a\'+i);\n                    count[i]--;\n                }\n            }\n            // if all the characters are used then terminate\n            if(!found) {\n                break;\n            }\n        }\n        return ans;\n    }\n};\n```\n***Please upvote if you have got any help from my code. Thank you.***
['C']