C++ intuitive solution
\nclass Solution \n{\n    public:\n    string sortString(string s) \n    {\n        string result="";\n        int a[26];\n        memset(a,0,sizeof(a));\n     
```\nclass Solution \n{\n    public:\n    string sortString(string s) \n    {\n        string result="";\n        int a[26];\n        memset(a,0,sizeof(a));\n        for(int i=0;i<s.length();i++) //counts of each alphabet\n        {\n            a[s[i]-\'a\']++;\n        }\n        while(true)\n        {\n            int flag=0;\n            for(int i=0;i<26;i++) //from smallest to largest\n            {\n                if(a[i]>0)\n                {\n                    result+=(char)(i+\'a\');\n                    a[i]--;\n                    flag=1;\n                }\n            }\n            for(int i=25;i>-1;i--) //from largest to smallest\n            {\n                if(a[i]>0)\n                {\n                    result+=(char)(i+\'a\');\n                    a[i]--;\n                    flag=1;\n                }\n            }\n            if(flag==0)\n            {\n                break;\n            }\n        }\n        return result;\n    }\n};\n```
[]