Simple Javascript
\nvar sortString = function (s) {\n  let arr = Array.from(s), ret = \'\';\n\n  arr.sort();\n\n  while (arr.length) {\n    arr = arr.filter((x, i) => {\n      if
```\nvar sortString = function (s) {\n  let arr = Array.from(s), ret = \'\';\n\n  arr.sort();\n\n  while (arr.length) {\n    arr = arr.filter((x, i) => {\n      if (i === 0 || x !== ret[ret.length - 1]) {\n        ret += x;\n        return false;\n      }\n      return true;\n    });\n\n    arr.reverse();\n  }\n\n  return ret;\n};\n```
['JavaScript']