Python solution
\th = collections.Counter(s)\n\tkeys = sorted(h.keys())\n\tresult = ""\n\twhile h:\n\t\tfor k in keys:\n\t\t\tif h[k]:\n\t\t\t\tresult += k\n\t\t\t\th[k] -= 1\n
\th = collections.Counter(s)\n\tkeys = sorted(h.keys())\n\tresult = ""\n\twhile h:\n\t\tfor k in keys:\n\t\t\tif h[k]:\n\t\t\t\tresult += k\n\t\t\t\th[k] -= 1\n\t\t\t\tif h[k] == 0:\n\t\t\t\t\tdel h[k]\n\t\tkeys = keys[::-1]\n\treturn result
[]