So, you have a random list (random meaning it doesn't matter what order it is in) of numbers with a length of n
, where n is a positive integer smaller than 1000 and larger than 1.
The random list must contain every number from 0 to (n - 1)
. Eg: [0, 3, 2, 5, 1, 4] (where n is 6).
Note: If there is more than one digit you do not translate like English - 11 is not "eleven", it is "one one".
Your task is to sort these numbers, but there are some difference to normal sorting:
You have to sort them as if they were the numbers expressed as words, in alphabetical order, but you cannot replace the numbers with letters [1]
At any given time, the list must contain exactly the same numbers in the exact quantities as the original list, you cannot add or remove any
Test Cases
n = 6
[0, 3, 2, 5, 1, 4] = [5, 4, 1, 3, 2, 0] (sorted like this but not this - ["five", "four", "one", "three", "two", "zero"])
n = 8
[0, 3, 7, 2, 5, 1, 6, 4] = [5, 4, 1, 7, 6, 3, 2, 0] (sorted like this but not this - ["five", "four", "one", "seven", "six", "three", "two", "zero"])
This is code-golf
, so the smallest answer in bytes wins.
[1]: You may create another list to do the sorting, but the original list must have the same contents at all times
101
one hundred and one, one hundred one, one zero one ... or ... what? \$\endgroup\$n
, since the output is going to be sorted anyway \$\endgroup\$