Sort spelled-out serial numbers Given a list of two or more spelled-out serial numbers of equal length greater than two, e.g.
[[ &quot;three&quot; , &quot;one&quot;  , &quot;four&quot;  ],
 [ &quot;one&quot;   , &quot;five&quot; , &quot;nine&quot;  ],
 [ &quot;two&quot;   , &quot;six&quot;  , &quot;five&quot;  ],
 [ &quot;three&quot; , &quot;five&quot; , &quot;eight&quot; ]]

sort the list by the numbers that the words represent:
[[ &quot;one&quot;   , &quot;five&quot; , &quot;nine&quot;  ],
 [ &quot;two&quot;   , &quot;six&quot;  , &quot;five&quot;  ],
 [ &quot;three&quot; , &quot;one&quot;  , &quot;four&quot;  ],
 [ &quot;three&quot; , &quot;five&quot; , &quot;eight&quot; ]]

You may require the numbers to be spelled in lower or upper, but not mixed, case.
Test cases
[[&quot;three&quot;,&quot;one&quot;,&quot;four&quot;],[&quot;one&quot;,&quot;five&quot;,&quot;nine&quot;],[&quot;two&quot;,&quot;six&quot;,&quot;five&quot;],[&quot;three&quot;,&quot;five&quot;,&quot;eight&quot;]]gives[[&quot;one&quot;,&quot;five&quot;,&quot;nine&quot;],[&quot;two&quot;,&quot;six&quot;,&quot;five&quot;],[&quot;three&quot;,&quot;one&quot;,&quot;four&quot;],[&quot;three&quot;,&quot;five&quot;,&quot;eight&quot;]]
[[&quot;two&quot;,&quot;seven&quot;],[&quot;one&quot;,&quot;eight&quot;],[&quot;two&quot;,&quot;eight&quot;],[&quot;one&quot;,&quot;eight&quot;],[&quot;two&quot;,&quot;eight&quot;],[&quot;four&quot;,&quot;five&quot;]]gives[[&quot;one&quot;,&quot;eight&quot;],[&quot;one&quot;,&quot;eight&quot;],[&quot;two&quot;,&quot;seven&quot;],[&quot;two&quot;,&quot;eight&quot;],[&quot;two&quot;,&quot;eight&quot;],[&quot;four&quot;,&quot;five&quot;]]
[[&quot;one&quot;,&quot;four&quot;,&quot;one&quot;,&quot;four&quot;,&quot;two&quot;],[&quot;one&quot;,&quot;three&quot;,&quot;five&quot;,&quot;six&quot;,&quot;two&quot;],[&quot;three&quot;,&quot;seven&quot;,&quot;three&quot;,&quot;zero&quot;,&quot;nine&quot;]]gives[[&quot;one&quot;,&quot;three&quot;,&quot;five&quot;,&quot;six&quot;,&quot;two&quot;],[&quot;one&quot;,&quot;four&quot;,&quot;one&quot;,&quot;four&quot;,&quot;two&quot;],[&quot;three&quot;,&quot;seven&quot;,&quot;three&quot;,&quot;zero&quot;,&quot;nine&quot;]]
[[&quot;zero&quot;,&quot;six&quot;,&quot;one&quot;],[&quot;eight&quot;,&quot;zero&quot;,&quot;three&quot;],[&quot;three&quot;,&quot;nine&quot;,&quot;eight&quot;],[&quot;eight&quot;,&quot;seven&quot;,&quot;four&quot;],[&quot;nine&quot;,&quot;eight&quot;,&quot;nine&quot;],[&quot;four&quot;,&quot;eight&quot;,&quot;four&quot;]]gives[[&quot;zero&quot;,&quot;six&quot;,&quot;one&quot;],[&quot;three&quot;,&quot;nine&quot;,&quot;eight&quot;],[&quot;four&quot;,&quot;eight&quot;,&quot;four&quot;],[&quot;eight&quot;,&quot;zero&quot;,&quot;three&quot;],[&quot;eight&quot;,&quot;seven&quot;,&quot;four&quot;],[&quot;nine&quot;,&quot;eight&quot;,&quot;nine&quot;]]
Husk, 9 8 bytes

Ö†€¨tfṡn


Try it online!

Algorithm "inspired" by recursive's Stax answer (I've just changed the lookup string a bit), go upvote him!

The trick is mapping each letter to its position in the string tfsen (compressed at the end of this program). Husks lists are 1-based, and missing items return 0, so we get this mapping:

"one"        [0,5,4]
"two"        [1,0,0]
"three"      [1,0,0,4,4]
"four"       [2,0,0,0]
"five"       [2,0,0,4]
"six"        [3,0,0]
"seven"      [3,4,0,4,5]
"eight"      [4,0,0,0,1]
"nine"       [5,0,5,4]


As you can see, the lists are perfectly ordered.



In order to be clear, here's how list comparison works in Husk (and in many other languages): 


If one of the two lists is empty, that's the smaller one.
If the first elements of the two lists are different, the one with the smaller first element is the smaller list.
Otherwise, discard the first element from both lists and go back to point 1.