🔥 JavaScript 🔥 HashMap 💡 Readable and Easy to understand solution
Code\n\n/**\n * @param {string} s\n * @return {string}\n */\nvar sortString = function (s) {\n  const map = new Array(26).fill(0);\n\n  for (const char of s) {\
# Code\n```\n/**\n * @param {string} s\n * @return {string}\n */\nvar sortString = function (s) {\n  const map = new Array(26).fill(0);\n\n  for (const char of s) {\n    const charCode = char.charCodeAt(0) - 97;\n    map[charCode]++;\n  }\n\n  function appendCharToRes(i) {\n    const char = String.fromCharCode(i + 97);\n    res += char;\n    map[i]--;\n  }\n\n  let res = "";\n\n  while (res.length !== s.length) {\n    for (let i = 0; i < map.length; i++) {\n      if (!map[i]) continue;\n      appendCharToRes(i);\n    }\n\n    for (let i = map.length - 1; i >= 0; i--) {\n      if (!map[i]) continue;\n      appendCharToRes(i);\n    }\n  }\n\n  return res;\n};\n```
['Hash Table', 'JavaScript']