4 lines Python, sort by key
\ndef sortString(self, s):\n    def key(c, phase={}):\n        p = phase[c] = phase.get(c, -1) + 1\n        return p, ord(c) * (-1)**p\n    return \'\'.join(sor
```\ndef sortString(self, s):\n    def key(c, phase={}):\n        p = phase[c] = phase.get(c, -1) + 1\n        return p, ord(c) * (-1)**p\n    return \'\'.join(sorted(s, key=key))\n```\nGets accepted in about 72 ms.\n\nFor example for input string `aabbb`, the keys are:\n```\nFirst \'a\':  (0, 97)\nSecond \'a\': (1, -97)\nFirst \'b\':  (0, 98)\nSecond \'b\': (1, -98)\nThird \'b\':  (2, 98)\n```\nSo then sorting sorts by phase and inside each phase by ascending or descending character:\n```\nPhase 0: (0, 97), (0, 98)     (first \'a\', first \'b\')\nPhase 1: (1, -98), (1, -97)   (second \'b\', second \'a\')\nPhase 2: (2, 98)              (third \'b\')\n```
[]