The Original Number (II) This challenge is essentially identical to this one with just one difference: it is now allowed to shuffle letters anywhere in the string.
Scenario
John has an important number, and he doesn't want others to see it.
He decided to encrypt the number, using the following steps:
His number is always a non-decreasing sequence (ie. &quot;1123&quot;)
He converted each digit into English words. (ie. &quot;123&quot; -&gt; &quot;ONETWOTHREE&quot;)
And then, rearrange the letters randomly. (ie. &quot;ONETWOTHREE&quot; -&gt; &quot;EEWOOHRNTET&quot;)
John felt that his number were safe in doing so. In fact, such encryption can be easily decrypted :(

Task
Given the encrypted string s, your task is to decrypt it and return the original number.

Rules

This is code golf, so the shortest answer in bytes wins
You can assume that the input string is always valid
The input string only contains uppercase letters
The original numbers are always arranged in ascending order
You may return the number in string or integer format
The letters will only be shuffled between one word, not between the whole string. The letters can be shuffled anywhere in the string.
The numbers will only be from 1 to 9 inclusive (ONE to NINE)


Possible Unscrambled String
Here is a list of the strings just after they have been converted to strings from the numbers:
 1 -&gt; ONE 
 2 -&gt; TWO
 3 -&gt; THREE
 4 -&gt; FOUR
 5 -&gt; FIVE
 6 -&gt; SIX
 7 -&gt; SEVEN
 8 -&gt; EIGHT
 9 -&gt; NINE


Examples
&quot;NEO&quot; -&gt; 1
&quot;NWEOOT&quot; -&gt; 12
&quot;TOEERWNEHOT&quot; -&gt; 123
&quot;IHNEVGENNEISTE&quot; -&gt; 789
&quot;WEETVTRFSVUHNEEFRHIXEOINSNIEGTOONIEE&quot; -&gt; 123456789
&quot;EWHEWROETOTTON&quot; -&gt; 1223
&quot;ONEWESTV&quot; -&gt; 27 (thanks, ETHproductions!)
Python 2, 123 bytes
c=map(input().count,&quot;OWHUFXSGIQ&quot;)
i=4
for j in&quot;71735539994&quot;:c[i*2]-=c[int(j)];i=-~i%5
s=&quot;&quot;
for n in c:i+=1;s+=`i`*n
print s

A full program taking quoted input and printing John's number.
Try it online! or see a test-suite
How?
Let's work with the example &quot;NEONSEXTOWNII&quot; (to yield 1269, and be somewhat Leisure Suite Larry-esque!)
First c=map(input().count,&quot;OWHUFXSGIQ&quot;) takes input and counts the number of each of OWHUFXSGIQ - these are letters that appear in each number in ascending order, with 2,4,6, and 8 having their &quot;own&quot; letters (WUXG), plus an extra letter, Q to append a zero to the the end and make the length of the resulting list even. For the example:
[2,1,0,0,0,1,1,0,2,0] &lt;- c
 O W H U F X S G I Q  &lt;- is the counts of these letters
 1 2 3 4 5 6 7 8 9 0  &lt;- which &quot;relate to&quot; these digits in John's number
   2   4   6   8   0  &lt;- these will be correct as the letters are unique to their words

The entries for 1, 3, 5, 7, and 9 need adjusting to correct the abundance of the other letters. This is performed by the next loop:
i=4
for j in&quot;71735539994&quot;:c[i*2]-=c[int(j)];i=-~i%5

Note that the entries to adjust are alternate ones (1,3,5,7,9,1,3,5,...), so we can add two to an index variable at each step and modulo by 10 to stay in range if we need to traverse more than once (which we do). To save some bytes we can increment by one and modulo by 5 and use double the index.
Since the adjustments for 9 require the most work we start there - it resides at index 8 so we start at i=4.
The string &quot;71735539994&quot; then gives the indexes, j, of the values to remove at each stage (where we have ensured the ninth index will contain zero by using &quot;Q&quot; when creating c); c[i*2]-=c[int(j)] performs each individual adjustment and i=-~i%5 moves i to the next index (where -~i is -(-1-i) or i+1 saving parentheses (i+1)%5) keeping i*2 within the bounds of c.
Thus we first subtract the number at index j=7 from that at index i*2=8, subtracting the number of &quot;G&quot;s counted from the number of &quot;I&quot;s, adjusting the &quot;NINE&quot; count down by the (correct) number of &quot;EIGHT&quot;s (which also has an &quot;I&quot;). We then move onto i=0 (-~4%5 = (4+1)%5 = 0), referencing index i*2 = 0 which is for &quot;ONE&quot; and subtract the value found at index j=1 the entry counting &quot;W&quot; and hence &quot;TWO&quot;, adjusting the count of &quot;O&quot;s down. By the end of the loop we have the corrected counts:
[1,1,0,0,0,1,0,0,1,0] &lt;- c   (for 1223333448 it would be: [1,2,4,2,0,0,0,1,0,0])
 1 2 3 4 5 6 7 8 9 0

so all that remains is to print out what c now represents (1269). i is now back at 0, so we increment it at the start of the loop and use it as our digit:
s=&quot;&quot;
for n in c:i+=1;s+=`i`*n
print s

The back ticks, `i`, are Python2 shorthand for repr(i) which gets a string representation of an object (the digit character in question as a string) and multiplying a string by a number creats a new string of that many repeats (here we only show n=0 turning `i` from say &quot;5&quot; to &quot;&quot; and n=1 turning keeping say &quot;6&quot; as &quot;6&quot;, but it also works for larger positive integers, so &quot;3&quot;*4 becomes &quot;3333&quot; for example.)