Simple python 3 solution
\n    def sortString(self, s: str) -> str:\n        storage = {}\n        for ch in s:\n            if ch in storage:\n                storage[ch] += 1\n       
```\n    def sortString(self, s: str) -> str:\n        storage = {}\n        for ch in s:\n            if ch in storage:\n                storage[ch] += 1\n            else:\n                storage[ch] = 1\n        result = []\n        smallest = True\n        while storage:\n            keys = [key for key in storage]\n            keys = sorted(keys) if smallest else sorted(keys, reverse=True)\n            smallest = not smallest\n            for key in keys:\n                result.append(key)\n                if storage[key] == 1:\n                    del storage[key]\n                else:\n                    storage[key] -= 1\n        return \'\'.join(result)\n\n```
['Python3']