JavaScript  solution
javascript\nvar sortString = function(s) {\n    let temp = new Array(26).fill(0);\n    let ans = [];\n    \n    for (let i=0; i<s.length; i++) {\n        temp[s
``` javascript\nvar sortString = function(s) {\n    let temp = new Array(26).fill(0);\n    let ans = [];\n    \n    for (let i=0; i<s.length; i++) {\n        temp[s.charCodeAt(i) - 97] += 1;   \n    }\n   \n    let flag = true;\n    while(ans.length < s.length) {\n       for (let i=0; i<temp.length; i++) {\n           var pos = i;\n           if (!flag) {\n               pos = 25-i;\n           }\n           if (temp[pos] !==0) {\n               ans.push(String.fromCharCode(pos+97));\n               temp[pos] -= 1;\n           }\n       }\n        \n       flag = !flag; \n    }\n    ans = ans.join(\'\');\n    \n    return ans;\n};\n```
['JavaScript']