Java 2ms 100% time 70% space well explained with comments
\npublic String sortString(String s) {\n       //first initialising i with length of the string\n        int i=s.length();\n\t\t//String builder to get  the res
```\npublic String sortString(String s) {\n       //first initialising i with length of the string\n        int i=s.length();\n\t\t//String builder to get  the result and for appending characters\n        StringBuilder d=new StringBuilder();\n\t\t//initialising counter array to count the characters and its length is 26 because  only lower case letters\n        int[] ar=new int[26];\n\t\t//increasing the count for each character in s\n        for(int j=0;j<i;j++){\n            ar[s.charAt(j)-\'a\']++;\n        }\n\t\t//Using while loop to check whether i > 0 so that String s has characters\n        while(i>0){\n\t\t//first of all appending all characters available in s(ascending order)  to d and decrementing the count and also i\n            for(int j=0;j<26;j++){\n                if(ar[j]>0){\n                d.append((char)(\'a\'+j));\n                    ar[j]--;\n                    i--;\n                    }\n            }\n\t\t\t//then in descending order until i becomes zero this while loop goes\n            for(int j=25;j>=0;j--){\n                if(ar[j]>0){\n                d.append((char)(\'a\'+j));\n                    ar[j]--;\n                    i--;\n                    }\n            }\n        }\n\t\t//converting String Builder to String\n        return d.toString();\n    }\n```
['String', 'Java']