Easy Java Solution
\nclass Solution {\n    public String sortString(String s) {\n        \n        //count the frequency of each character\n        int[] freq = new int[26];\n    
```\nclass Solution {\n    public String sortString(String s) {\n        \n        //count the frequency of each character\n        int[] freq = new int[26];\n        for(int i = 0; i < s.length(); i++){\n            int ch = s.charAt(i) - \'a\';\n            freq[ch]++;\n        }\n \n        String ans = "";\n        \n        //loop until both the answer string and given string\'s lengths are same\n        while(ans.length() != s.length()){  \n        \n            //loop over a to z\n        for(int i = 0; i < freq.length; i++){\n            if(freq[i] > 0){\n               \tchar c =(char) (i + \'a\');\n                ans+= c;\n                freq[i]--;\n            }\n        }\n        \n        //loop over z to a\n        for(int i = freq.length -1; i >= 0; i--){\n            if(freq[i] > 0){\n                char c =(char) (i + \'a\');\n                ans+= c;\n                freq[i]--;\n            }\n        }\n     }\n        return ans;\n   }\n}\n```
['Java']