<p>Given a string <code>s</code> containing an out-of-order English representation of digits <code>0-9</code>, return <em>the digits in <strong>ascending</strong> order</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> s = "owoztneoer"
<strong>Output:</strong> "012"
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> s = "fviefuro"
<strong>Output:</strong> "45"
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
	<li><code>s[i]</code> is one of the characters <code>[&quot;e&quot;,&quot;g&quot;,&quot;f&quot;,&quot;i&quot;,&quot;h&quot;,&quot;o&quot;,&quot;n&quot;,&quot;s&quot;,&quot;r&quot;,&quot;u&quot;,&quot;t&quot;,&quot;w&quot;,&quot;v&quot;,&quot;x&quot;,&quot;z&quot;]</code>.</li>
	<li><code>s</code> is <strong>guaranteed</strong> to be valid.</li>
</ul>

class Solution {
public:
    std::vector<std::pair<char, int>> compare= {{'x', 6}, {'z', 0}, {'g', 8}, {'w', 2}, {'s', 7}, {'h', 3}, {'v', 5}, {'f', 4}, {'o', 1}, {'e', 9} };
    string number[10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
    string originalDigits(string s) {
        int tot = 0;
        int charBufCnt[123] = {0};
        int digit[10] = {0};

        for(char c:s) {
            charBufCnt[c]++;
        }

        for(auto tmp:compare) {
            int n = charBufCnt[tmp.first];
            tot += n;
            digit[tmp.second] = n;

            for(char x:number[tmp.second]) {
                charBufCnt[x] -= n;
            }
        }

        string ret(tot, '*');
        for(int i=0, j=0;i<10;i++) {
            while(digit[i]--) {
                ret[j++] = i + '0';
            }
        }

        return ret;
    }
};
10200