17
1
Given a list of two or more spelled-out serial numbers of equal length greater than two, e.g.
[[ "three" , "one" , "four" ],
[ "one" , "five" , "nine" ],
[ "two" , "six" , "five" ],
[ "three" , "five" , "eight" ]]
sort the list by the numbers that the words represent:
[[ "one" , "five" , "nine" ],
[ "two" , "six" , "five" ],
[ "three" , "one" , "four" ],
[ "three" , "five" , "eight" ]]
You may require the numbers to be spelled in lower or upper, but not mixed, case.
Test cases
[["three","one","four"],["one","five","nine"],["two","six","five"],["three","five","eight"]]
gives[["one","five","nine"],["two","six","five"],["three","one","four"],["three","five","eight"]]
[["two","seven"],["one","eight"],["two","eight"],["one","eight"],["two","eight"],["four","five"]]
gives[["one","eight"],["one","eight"],["two","seven"],["two","eight"],["two","eight"],["four","five"]]
[["one","four","one","four","two"],["one","three","five","six","two"],["three","seven","three","zero","nine"]]
gives[["one","three","five","six","two"],["one","four","one","four","two"],["three","seven","three","zero","nine"]]
[["zero","six","one"],["eight","zero","three"],["three","nine","eight"],["eight","seven","four"],["nine","eight","nine"],["four","eight","four"]]
gives[["zero","six","one"],["three","nine","eight"],["four","eight","four"],["eight","zero","three"],["eight","seven","four"],["nine","eight","nine"]]
Not sure if I got this correctly, does
["three","one","four"] === 314
? – Nit – 2018-04-09T20:05:54.797@Nit Yes, that's right. – Adám – 2018-04-09T20:06:45.150
@Nit By the numbers they spell out. E.g.
[314,159,265,358]
→[159,265,314,358]
. – Adám – 2018-04-09T20:09:30.183Can we assume a certain arbitrary capitalization of the numbers? – dylnan – 2018-04-09T20:27:37.037
@dylnan
You may require the numbers to be spelled in lower or upper, but not mixed, case.
– totallyhuman – 2018-04-09T20:28:47.183I really need to learn to read... – dylnan – 2018-04-09T20:33:55.573
No APL friendly test cases format? ;) – Uriel – 2018-04-09T20:51:33.963
@Uriel Just use
↑⍣≡⎕JSON
. – Adám – 2018-04-09T20:57:07.193