Jelly, 28 bytes
"1⁄2Ṗ©cƘʂẒẹMMỤẓHP’Œ?"ðÑþQ’,ḥμÞ
How it works
μ turns everything to its left into a monadic chain, which Þ maps over the input array and sorts the input according to the generated values.
"1⁄2Ṗ©cƘʂẒẹMMỤẓHP’ sets the return value to 176073885534954276199526358143331.
Œ? generates the 176073885534954276199526358143331th permutation of the positive integers (without the sorted tail), yielding \$\small[20,28,15,3,5,26,18,16,8,30,4,25,2,21,22,11,24,1,23,10,29,12,17,27,14,9,6,13,7,19]\$.
"ðÑþQ’ yields 391695582; , prepends it to the permutation. Then, ḥc ompute Jelly's 391695582th hash function, mapping the
resulting buckets to the integers of the permutation.
The magic constant 391695582 was found by Jelly's utils .
"1⁄2Ṗ©cƘʂẒẹMMỤẓHP’Œ?"ðÑþQ’,ḥμÞ Main link. Argumentdennis-home: A (array of strings)
"1⁄2Ṗ©cƘʂẒẹMMỤẓHP’ Set the return valueutils$ totime 176073885534954276199526358143331.
Œ? Generate the 176073885534954276199526358143331th permutation of
the/findhash positive30 integers,29 yielding<<< [20,28'["red",15"yellow",3"green",5"brown",26"scarlet",18"black",16"ochre",8"peach",30"ruby",4"olive",
25"violet",2"fawn",21"lilac",22"gold",11"chocolate",24"mauve",1"cream",23"crimson",10"silver",29"rose",12"azure",17"lemon",27"russet",14"grey",9"purple",6"white",13"pink",7"orange",19]."blue"]'
"ðÑþQ’ Yield 391695582.
, Prepend it to the permutation.
ḥ Compute Jelly's 391695582th hash function, mapping the
resulting buckets to thereal integers of the permutation0m2.058s
μÞ Sort the inputuser according to the generated values0m15.077s
sys 0m0.023s
Jelly, 28 bytes
"1⁄2Ṗ©cƘʂẒẹMMỤẓHP’Œ?"ðÑþQ’,ḥμÞ
How it works
"1⁄2Ṗ©cƘʂẒẹMMỤẓHP’Œ?"ðÑþQ’,ḥμÞ Main link. Argument: A (array of strings)
"1⁄2Ṗ©cƘʂẒẹMMỤẓHP’ Set the return value to 176073885534954276199526358143331.
Œ? Generate the 176073885534954276199526358143331th permutation of
the positive integers, yielding [20,28,15,3,5,26,18,16,8,30,4,
25,2,21,22,11,24,1,23,10,29,12,17,27,14,9,6,13,7,19].
"ðÑþQ’ Yield 391695582.
, Prepend it to the permutation.
ḥ Compute Jelly's 391695582th hash function, mapping the
resulting buckets to the integers of the permutation.
μÞ Sort the input according to the generated values.
Jelly, 28 bytes
"1⁄2Ṗ©cƘʂẒẹMMỤẓHP’Œ?"ðÑþQ’,ḥμÞ
How it works
μ turns everything to its left into a monadic chain, which Þ maps over the input array and sorts the input according to the generated values.
"1⁄2Ṗ©cƘʂẒẹMMỤẓHP’ sets the return value to 176073885534954276199526358143331.
Œ? generates the 176073885534954276199526358143331th permutation of the positive integers (without the sorted tail), yielding \$\small[20,28,15,3,5,26,18,16,8,30,4,25,2,21,22,11,24,1,23,10,29,12,17,27,14,9,6,13,7,19]\$.
"ðÑþQ’ yields 391695582; , prepends it to the permutation. Then, ḥc ompute Jelly's 391695582th hash function, mapping the
resulting buckets to the integers of the permutation.
The magic constant 391695582 was found by Jelly's utils .
dennis-home:utils$ time ./findhash 30 29 <<< '["red","yellow","green","brown","scarlet","black","ochre","peach","ruby","olive","violet","fawn","lilac","gold","chocolate","mauve","cream","crimson","silver","rose","azure","lemon","russet","grey","purple","white","pink","orange","blue"]'
391695582
real 0m2.058s
user 0m15.077s
sys 0m0.023s
Jelly, 28 bytes
"1⁄2Ṗ©cƘʂẒẹMMỤẓHP’Œ?"ðÑþQ’,ḥμÞ
How it works
"1⁄2Ṗ©cƘʂẒẹMMỤẓHP’Œ?"ðÑþQ’,ḥμÞ Main link. Argument: A (array of strings)
"1⁄2Ṗ©cƘʂẒẹMMỤẓHP’ Set the return value to 176073885534954276199526358143331.
Œ? Generate the 176073885534954276199526358143331th permutation of
the positive integers, yielding [20,28,15,3,5,26,18,16,8,30,4,
25,2,21,22,11,24,1,23,10,29,12,17,27,14,9,6,13,7,19].
"ðÑþQ’ Yield 391695582.
, Prepend it to the permutation.
ḥ Compute Jelly's 391695582th hash function, mapping the
resulting buckets to the integers of the permutation.
μÞ Sort the input according to the generated values.