Coat of Many Colours












22














Challenge



Given a list of unique colour names as input, sort them in the order that they first appear in Joseph's Amazing Technicolour Dreamcoat.





Example



Input:  green, blue, red, brown
Output: red, green, brown, blue


The full list of colours, in order, is:



 1. red
2. yellow
3. green
4. brown
5. scarlet
6. black
7. ochre
8. peach
9. ruby
10. olive
11. violet
12. fawn
13. lilac
14. gold
15. chocolate
16. mauve
17. cream
18. crimson
19. silver
20. rose
21. azure
22. lemon
23. russet
24. grey
25. purple
26. white
27. pink
28. orange
29. blue


Or as an array of strings:



["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"]




Rules




  • You may take input by any reasonable, convenient means (e.g., an array of strings, a delimited string, individual strings) as long as it's permitted by our standard I/O rules, but please specify your input method in your answer.

  • You may do the same for your output.

  • The input will only ever contain colours from the above list.

  • Your solution should be able to handle empty inputs.

  • You may choose whether all words in the input are consistently uppercase, lowercase or title case but your output's casing must match your input's.

  • This is code-golf so lowest byte count in each language wins.

  • As always, standard loopholes are forbidden.




Test cases



Input:  
Output:

Input: ["green", "blue", "red", "brown"]
Output: ["red", "green", "brown", "blue"]

Input: ["gold", "grey", "green"]
Output: ["green", "gold", "grey"]

Input: ["ruby","yellow","red","grey"]
Output: ["red", "yellow", "ruby", "grey"]

Input: ["gold", "green", "fawn", "white", "azure", "rose", "black", "purple", "orange", "silver", "ruby", "blue", "lilac", "crimson", "pink", "cream", "lemon", "russet", "grey", "olive", "violet", "mauve", "chocolate", "yellow", "peach", "brown", "ochre", "scarlet", "red"]
Output: ["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"]









share|improve this question




















  • 1




    Sandbox (hard to believe it'd been languishing there for 18 months!)
    – Shaggy
    Dec 19 '18 at 16:20


















22














Challenge



Given a list of unique colour names as input, sort them in the order that they first appear in Joseph's Amazing Technicolour Dreamcoat.





Example



Input:  green, blue, red, brown
Output: red, green, brown, blue


The full list of colours, in order, is:



 1. red
2. yellow
3. green
4. brown
5. scarlet
6. black
7. ochre
8. peach
9. ruby
10. olive
11. violet
12. fawn
13. lilac
14. gold
15. chocolate
16. mauve
17. cream
18. crimson
19. silver
20. rose
21. azure
22. lemon
23. russet
24. grey
25. purple
26. white
27. pink
28. orange
29. blue


Or as an array of strings:



["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"]




Rules




  • You may take input by any reasonable, convenient means (e.g., an array of strings, a delimited string, individual strings) as long as it's permitted by our standard I/O rules, but please specify your input method in your answer.

  • You may do the same for your output.

  • The input will only ever contain colours from the above list.

  • Your solution should be able to handle empty inputs.

  • You may choose whether all words in the input are consistently uppercase, lowercase or title case but your output's casing must match your input's.

  • This is code-golf so lowest byte count in each language wins.

  • As always, standard loopholes are forbidden.




Test cases



Input:  
Output:

Input: ["green", "blue", "red", "brown"]
Output: ["red", "green", "brown", "blue"]

Input: ["gold", "grey", "green"]
Output: ["green", "gold", "grey"]

Input: ["ruby","yellow","red","grey"]
Output: ["red", "yellow", "ruby", "grey"]

Input: ["gold", "green", "fawn", "white", "azure", "rose", "black", "purple", "orange", "silver", "ruby", "blue", "lilac", "crimson", "pink", "cream", "lemon", "russet", "grey", "olive", "violet", "mauve", "chocolate", "yellow", "peach", "brown", "ochre", "scarlet", "red"]
Output: ["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"]









share|improve this question




















  • 1




    Sandbox (hard to believe it'd been languishing there for 18 months!)
    – Shaggy
    Dec 19 '18 at 16:20
















22












22








22


4





Challenge



Given a list of unique colour names as input, sort them in the order that they first appear in Joseph's Amazing Technicolour Dreamcoat.





Example



Input:  green, blue, red, brown
Output: red, green, brown, blue


The full list of colours, in order, is:



 1. red
2. yellow
3. green
4. brown
5. scarlet
6. black
7. ochre
8. peach
9. ruby
10. olive
11. violet
12. fawn
13. lilac
14. gold
15. chocolate
16. mauve
17. cream
18. crimson
19. silver
20. rose
21. azure
22. lemon
23. russet
24. grey
25. purple
26. white
27. pink
28. orange
29. blue


Or as an array of strings:



["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"]




Rules




  • You may take input by any reasonable, convenient means (e.g., an array of strings, a delimited string, individual strings) as long as it's permitted by our standard I/O rules, but please specify your input method in your answer.

  • You may do the same for your output.

  • The input will only ever contain colours from the above list.

  • Your solution should be able to handle empty inputs.

  • You may choose whether all words in the input are consistently uppercase, lowercase or title case but your output's casing must match your input's.

  • This is code-golf so lowest byte count in each language wins.

  • As always, standard loopholes are forbidden.




Test cases



Input:  
Output:

Input: ["green", "blue", "red", "brown"]
Output: ["red", "green", "brown", "blue"]

Input: ["gold", "grey", "green"]
Output: ["green", "gold", "grey"]

Input: ["ruby","yellow","red","grey"]
Output: ["red", "yellow", "ruby", "grey"]

Input: ["gold", "green", "fawn", "white", "azure", "rose", "black", "purple", "orange", "silver", "ruby", "blue", "lilac", "crimson", "pink", "cream", "lemon", "russet", "grey", "olive", "violet", "mauve", "chocolate", "yellow", "peach", "brown", "ochre", "scarlet", "red"]
Output: ["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"]









share|improve this question















Challenge



Given a list of unique colour names as input, sort them in the order that they first appear in Joseph's Amazing Technicolour Dreamcoat.





Example



Input:  green, blue, red, brown
Output: red, green, brown, blue


The full list of colours, in order, is:



 1. red
2. yellow
3. green
4. brown
5. scarlet
6. black
7. ochre
8. peach
9. ruby
10. olive
11. violet
12. fawn
13. lilac
14. gold
15. chocolate
16. mauve
17. cream
18. crimson
19. silver
20. rose
21. azure
22. lemon
23. russet
24. grey
25. purple
26. white
27. pink
28. orange
29. blue


Or as an array of strings:



["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"]




Rules




  • You may take input by any reasonable, convenient means (e.g., an array of strings, a delimited string, individual strings) as long as it's permitted by our standard I/O rules, but please specify your input method in your answer.

  • You may do the same for your output.

  • The input will only ever contain colours from the above list.

  • Your solution should be able to handle empty inputs.

  • You may choose whether all words in the input are consistently uppercase, lowercase or title case but your output's casing must match your input's.

  • This is code-golf so lowest byte count in each language wins.

  • As always, standard loopholes are forbidden.




Test cases



Input:  
Output:

Input: ["green", "blue", "red", "brown"]
Output: ["red", "green", "brown", "blue"]

Input: ["gold", "grey", "green"]
Output: ["green", "gold", "grey"]

Input: ["ruby","yellow","red","grey"]
Output: ["red", "yellow", "ruby", "grey"]

Input: ["gold", "green", "fawn", "white", "azure", "rose", "black", "purple", "orange", "silver", "ruby", "blue", "lilac", "crimson", "pink", "cream", "lemon", "russet", "grey", "olive", "violet", "mauve", "chocolate", "yellow", "peach", "brown", "ochre", "scarlet", "red"]
Output: ["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"]






code-golf array-manipulation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 19 '18 at 23:22

























asked Dec 19 '18 at 16:19









Shaggy

18.9k21666




18.9k21666








  • 1




    Sandbox (hard to believe it'd been languishing there for 18 months!)
    – Shaggy
    Dec 19 '18 at 16:20
















  • 1




    Sandbox (hard to believe it'd been languishing there for 18 months!)
    – Shaggy
    Dec 19 '18 at 16:20










1




1




Sandbox (hard to believe it'd been languishing there for 18 months!)
– Shaggy
Dec 19 '18 at 16:20






Sandbox (hard to believe it'd been languishing there for 18 months!)
– Shaggy
Dec 19 '18 at 16:20












13 Answers
13






active

oldest

votes


















9















PowerShell, 262 155 151 127 125 95 bytes





$args|sort{"rlyegwbrscbrocpyrvo lvnfaldgccvmacmcvseraolsrygpptwkpnoeb".indexof((-join$_[3,0]))}


Try it online!



Naive approach. PowerShell sort-object can sort based on a script block that gets executed for every object. Here we're simply getting the .IndexOf() the color from a string, which will assign a numerical value to each color, and then sorts based on those numbers. The string is constructed from the fourth and first letters of each color to ensure uniqueness. Output is implicit.



-4 bytes thanks to Shaggy.
-2 bytes thanks to mazzy.
A whopping -30 bytes thanks to KGlasier.






share|improve this answer























  • I don't know if you could do this efficiently (byte-wise), but if you sort by length 3 substrings and then sort with secondary key of the original string, the only collision is green grey which is in the right alphabetical order.
    – HyperNeutrino
    Dec 19 '18 at 17:09






  • 2




    @Shaggy Yes, that works because .IndexOf() will return -1 if the string isn't found, which sorts red into the right ordering. Thanks!
    – AdmBorkBork
    Dec 19 '18 at 17:13










  • i think you can remove brackets around a string.
    – mazzy
    Dec 19 '18 at 18:22










  • @mazzy Indeed, thanks!
    – AdmBorkBork
    Dec 19 '18 at 18:39






  • 1




    @KGlasier Wow, thanks for finding that string! That saves a lot of bytes.
    – AdmBorkBork
    Dec 20 '18 at 13:37



















8















JavaScript (SpiderMonkey),  106 105  104 bytes



"When in doubt, just hash the bloody input."





a=>a.sort((a,b)=>(g=s=>'i0008bar5dj60007f3001p09mseqg0hk40cnl2o'[parseInt(s,36)*50%257%170%40])(a)>g(b))


Try it online!






share|improve this answer























  • I've seen (and been impressed by) hash-based solutions like this before. Is there an explanation anywhere for how the magic string/multiplier/mod values are generated? Is it just brute force until you find a set of values that gives a unique output for each of the possible color inputs, or is there a more clever approach?
    – Jack Brounstein
    Dec 19 '18 at 19:03






  • 1




    @JackBrounstein This one was just a quick and dirty brute force search trying random values and minimizing only the maximum output (after the last modulo), without taking the length of the full chain into account (e.g. %99%55 is not better than %123%55 with this approach). So it's certainly sub-optimal. I may try something slightly more sophisticated later, though.
    – Arnauld
    Dec 19 '18 at 19:09



















5















Jelly, 28 bytes



“½Ṗ©cƘʂẒẹMMỤẓHP’Œ?“ðÑþQ’,ḥµÞ


Try it online!



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.



“½Ṗ©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





share|improve this answer



















  • 1




    353690280752 hashes the 29 colors in 29 buckets, but takes one more byte to encode. Using uppercase (332849952364) or titlecase (862442225888) also comes out at 28 bytes.
    – Dennis
    Dec 20 '18 at 2:24



















4















Python 3, 93 bytes





lambda r:sorted(r,key=lambda s:'iV^ZzwnFM@pYuOobXGAKyf[tUR]E'.find(chr(int(s,36)%127%60+64)))


Try it online!



Reads each color as a base-36 int. Brute-forced the moduli and chose an arbitrary offset among the 19 that didn't require escapes.






share|improve this answer





























    3














    I will improve the string compression in a while




    Japt, 88 78 71 bytes



    ñ@`䊐âwrÒ.cÖ¨acru½ivo¤faØngoÒqauvœamsolv€osz¨e¶s gœrpl–tpˆ„g½u`bXé4 ¯3


    Try it online!






    share|improve this answer























    • A quick port of one of the other solutions here comes in at 46 bytes, if you want to try for it.
      – Shaggy
      Dec 20 '18 at 13:34



















    3














    Wolfram Language 255 213 199 bytes



    Fourteen bytes saved by Dennis, who avoided the " marks, using symbols instead of strings.



    SortBy[#,{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}~Position~#&]&


    Try It Online!






    share|improve this answer































      3














      Powershell, 124 120 124 119 118 102 bytes





      $args|sort{$c=$_
      'bluOrPiWPuG*yRusLeARoSiCriCrMCGoLFVOlRuPOBlSBGYR'-csplit'(?=[A-Z])'|%{$c-like"$_*"}}


      Try It Online!



      Explanation:




      1. The data string contains the first significant letters of the color labels in descending order. Except for the Grey label - G*y is shorter.


      2. -csplit'(?=[A-Z])' splits the data string to the array (blu,Or,Pi,W,Pu,G*y,Rus,Le,A,Ro,Si,Cri,Cr,M,C,Go,L,F,V,Ol,Ru,P,O,Bl,S,B,G,Y,R)


      3. |%{$c-like"$_*"} maps the string array to the array of boolean. Where True means "a color label starts from this string" (like is case-insensitive operator, csplit - case-sensitive. see doc).


      4. sort{} sorts a color lables by the arrays of boolean in ascending order.



      The sorting by array is a very interesting feature in the Powershell. In this script all arrays have the same length and contain Boolean values only. This sorting is performed in the lexographic order of boolean arrays.



      Therefore, the string can contain one-letter abbreviations for the last labels. If there is a match at the beginning of the array, the matches at the end have no effect.





             blu Or Pi W Pu G*y Rus Le A Ro Si Cri Cr M C Go L F V Ol Ru P O Bl S B G Y R
      green: - - - - - - - - - - - - - - - - - - - - - - - - - - T - -
      gold : - - - - - - - - - - - - - - - T - - - - - - - - - - T - -
      grey : - - - - - T - - - - - - - - - - - - - - - - - - - - T - -

      : green < gold < grey


      Where T is true and - is false.





      Test script:





      $f = {

      $args|sort{$c=$_
      'bluOrPiWPuG*yRusLeARoSiCriCrMCGoLFVOlRuPOBlSBGYR'-csplit'(?=[A-Z])'|%{$c-like"$_*"}}

      }

      @(
      ,( @(), @() )
      ,( ('green', 'blue', 'red', 'brown'), ('red', 'green', 'brown', 'blue') )
      ,( ("gold", "grey", "green"), ("green", "gold", "grey") )
      ,( ("ruby","yellow","red","grey"), ("red", "yellow", "ruby", "grey") )
      ,( ("gold", "green", "fawn", "white", "azure", "rose", "black", "purple", "orange", "silver", "ruby", "blue", "lilac", "crimson", "pink", "cream", "lemon", "russet", "grey", "olive", "violet", "mauve", "chocolate", "yellow", "peach", "brown", "ochre", "scarlet", "red"),
      ("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") )
      ) | % {
      $inp,$expected = $_
      $result = &$f @inp # splatting
      "$("$result"-eq"$expected"): $result"
      }


      Output:



      True:
      True: red green brown blue
      True: green gold grey
      True: red yellow ruby grey
      True: 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





      share|improve this answer























      • I have This site can’t be reached error. Sorry.
        – mazzy
        Dec 19 '18 at 22:16






      • 1




        Added a revised TIO for you.
        – Shaggy
        Dec 20 '18 at 17:02



















      2















      Python 2, 186 bytes





      lambda a:[y for x,y in sorted((max(" y gree br sc bla oc pe rub ol v f li go ch m cre cri si ro a le rus grey pu w pi or blu ".find(" %s "%c[:i+1])for i,j in enumerate(c)),c)for c in a)]


      Try it online!



      Finds all matches for progressive character substrings (Ex: "green" will check for "g", "gr", "gre", "gree", and "green") in the identifier string, and keeps the maximum index. "red" is always first, anf find() returns -1 for missing matches, so there is no identifier for red specifically.



      Once the colors are turned into (index, color) pairs, sorts array on first item of pair and then discards first item of each pair.






      share|improve this answer





























        2















        C# (Visual C# Interactive Compiler), 321 219 210 161 159 138 bytes





        n=>n.OrderBy(a=>a!="grey"?"yelgrebroscablaochperuboliviofawlilgolchomaucrecrisilrosazulemruspurwhipinorablu".IndexOf(a.Substring(0,3)):65)


        Try it online!



        -3 bytes thanks to Shaggy, -18 thanks to TheLethalCoder



        Takes input as a List<string>, returns an IOrderedEnumerable<string>



        How this works is that it orders the list by each string's index in the original string. The original string has every color except for grey turned to it's first three letters. Grey is not there, since green and grey would cause ambiguity. Red isn't there either, since IndexOf returns -1 if the string doesn't appear.






        share|improve this answer























        • I think you can remove red from your lookup string and replace 68 with 65 to save 3 bytes. On my phone so haven't fully tested it.
          – Shaggy
          Dec 20 '18 at 8:16










        • You can use the string inline with an implicit return for 142 bytes n=>n.OrderBy(a=>a!="grey"?"redyelgrebroscablaochperuboliviofawlilgolchomaucrecrisilrosazulemruspurwhipinorablu".IndexOf(a.Substring(0,3)):68); However, you need to include the usings in your byte count as they are required to run. You can use the namespace trick to shorten the count required though.
          – TheLethalCoder
          Dec 20 '18 at 11:51










        • If I use the namespace trick, do I have to add the namespace to my number of bytes?
          – Embodiment of Ignorance
          Dec 20 '18 at 16:34










        • I can just change the compiler to Visual C# Interactive Compiler, and then I won't have to add the usings
          – Embodiment of Ignorance
          Dec 20 '18 at 16:44










        • Ah good idea on changing to Interactive but yes if you did the namespace trick you'd have to include it in your byte count. Essentially adding namespace System.Linq{} or whatever you would have chosen.
          – TheLethalCoder
          Dec 20 '18 at 17:13



















        2















        Python 3, 130 bytes





        lambda*a:sorted(a,key=lambda c:("r,ylgebwsrtbcorpcryovvlfnlagdccamvca cmnsvrearlorsgyppwtpkonbe".find(c[::3]+" "*(c=="cream")),c))


        Try it online!






        share|improve this answer























        • @Shaggy I don't think so? can you give me an input and the intended output
          – HyperNeutrino
          Dec 19 '18 at 17:19










        • @AdmBorkBork Thanks, just realized what Shaggy meant by that. I was only comparing green and grey to each other lol
          – HyperNeutrino
          Dec 19 '18 at 17:21










        • To add to Shaggy and AdmBorkBork's comments, "green" and "grey" both begin with "gre".
          – DavidC
          Dec 19 '18 at 17:21










        • @Shaggy fixed i think
          – HyperNeutrino
          Dec 19 '18 at 17:23






        • 1




          @Shaggy Fixed it, thanks. Required a bit of a hack for cream since ca is a substring of cca for chocolate oof.
          – HyperNeutrino
          Dec 21 '18 at 15:48



















        1















        Charcoal, 69 68 63 56 bytes



        F⪪”E$↥l∧_∧K⁰RY⸿h⊕ψVG⌕gbW⟧⁼″5/²H✳<◨A³?ω↗⊘‴⭆1”²Φθ№κ⎇Σιlilι


        Try it online! Link is to verbose version of code. Explanation:



        F⪪”E$↥l∧_∧K⁰RY⸿h⊕ψVG⌕gbW⟧⁼″5/²H✳<◨A³?ω↗⊘‴⭆1”²


        Take the compressed string edyeeebrscckhrpeubivvifa99gohomaamrisiosazemuseypuwhpiorlu and loop over each substring of length 2.



        Φθ№κ⎇Σιlilι


        For each substring print those input strings that contain that substring, unless the substring is 99, in which case look for lil instead. (lilac is the only colour that does not have a unique two-letter substring; olive includes li; silver includes il and black includes lac. fawn and azure can be detected using just a single letter, but that doesn't help here.)






        share|improve this answer































          1














          Pyth, 66 bytes



          oxc."ayÇæ£ðÐ¥~@iF[2BÍÐ:Yë)^ksTTã"2s@LN,03


          Try it online here, or verify all the test cases at once here.



          The colours in the list can be uniquely identified by taking the characters at index 0 and 3, assuming modular indexing. This results in the following mapping:



          rr -> red
          yl -> yellow
          ge -> green
          bw -> brown
          sr -> scarlet
          bc -> black
          or -> ochre
          pc -> peach
          ry -> ruby
          ov -> olive
          vl -> violet
          fn -> fawn
          la -> lilac
          gd -> gold
          cc -> chocolate
          mv -> mauve
          ca -> cream
          cm -> crimson
          sv -> silver
          re -> rose
          ar -> azure
          lo -> lemon
          rs -> russet
          gy -> grey
          pp -> purple
          wt -> white
          pk -> pink
          on -> orange
          be -> blue


          Full explanation:



          oxc."..."2s@LN,03Q   Implicit: Q=eval(input())
          Trailing Q inferred, dictionary string replaced with ... for brevity
          o Q Order the elements of Q, as N, using:
          ,03 [0,3]
          @LN Get the characters at the above indices in N
          s Concatenate into a string
          The above is result {1}
          ."..." The compressed dictionary string
          c 2 Split into chunks of length 2
          x Get the index of {1} in the above
          Implicit print of sorted list





          share|improve this answer





























            1















            05AB1E, 48 bytes



            Σ.•Aå₂мÕh∊þèmvƶkΛ1YŠíJ>J#θ₁2©€,Ù{η¦ù-•2ôy¬s3è«k


            Same solution as most other answers. Will try to golf it down from here later.



            Try it online or verify all test cases.



            Explanation:





            Σ          # Sort the (implicit) input-list by:
            .•Aå₂мÕh∊þèmvƶkΛ1YŠíJ>J#θ₁2©€,Ù{η¦ù-•
            # Push compressed string "rrylgebwsrbcorpcryovvlfnlagdccmvcacmsvrearlorsgyppwtpkonbe"
            2ô # Split into parts of size 2
            y # Push the current string of the list we're sorting
            ¬ # Push its head (without popping)
            s # Swap so the string is at the top of the stack again
            3è # Get the character at index 3 (with automatic wraparound)
            « # Merge both characters together
            k # And get the index in the compressed string to sort on


            See this 05AB1E tip (section How to compress strings not part of the dictionary?) to understand how .•Aå₂мÕh∊þèmvƶkΛ1YŠíJ>J#θ₁2©€,Ù{η¦ù-• is "rrylgebwsrbcorpcryovvlfnlagdccmvcacmsvrearlorsgyppwtpkonbe".






            share|improve this answer





















              Your Answer





              StackExchange.ifUsing("editor", function () {
              return StackExchange.using("mathjaxEditing", function () {
              StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
              StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
              });
              });
              }, "mathjax-editing");

              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "200"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f177786%2fcoat-of-many-colours%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              13 Answers
              13






              active

              oldest

              votes








              13 Answers
              13






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              9















              PowerShell, 262 155 151 127 125 95 bytes





              $args|sort{"rlyegwbrscbrocpyrvo lvnfaldgccvmacmcvseraolsrygpptwkpnoeb".indexof((-join$_[3,0]))}


              Try it online!



              Naive approach. PowerShell sort-object can sort based on a script block that gets executed for every object. Here we're simply getting the .IndexOf() the color from a string, which will assign a numerical value to each color, and then sorts based on those numbers. The string is constructed from the fourth and first letters of each color to ensure uniqueness. Output is implicit.



              -4 bytes thanks to Shaggy.
              -2 bytes thanks to mazzy.
              A whopping -30 bytes thanks to KGlasier.






              share|improve this answer























              • I don't know if you could do this efficiently (byte-wise), but if you sort by length 3 substrings and then sort with secondary key of the original string, the only collision is green grey which is in the right alphabetical order.
                – HyperNeutrino
                Dec 19 '18 at 17:09






              • 2




                @Shaggy Yes, that works because .IndexOf() will return -1 if the string isn't found, which sorts red into the right ordering. Thanks!
                – AdmBorkBork
                Dec 19 '18 at 17:13










              • i think you can remove brackets around a string.
                – mazzy
                Dec 19 '18 at 18:22










              • @mazzy Indeed, thanks!
                – AdmBorkBork
                Dec 19 '18 at 18:39






              • 1




                @KGlasier Wow, thanks for finding that string! That saves a lot of bytes.
                – AdmBorkBork
                Dec 20 '18 at 13:37
















              9















              PowerShell, 262 155 151 127 125 95 bytes





              $args|sort{"rlyegwbrscbrocpyrvo lvnfaldgccvmacmcvseraolsrygpptwkpnoeb".indexof((-join$_[3,0]))}


              Try it online!



              Naive approach. PowerShell sort-object can sort based on a script block that gets executed for every object. Here we're simply getting the .IndexOf() the color from a string, which will assign a numerical value to each color, and then sorts based on those numbers. The string is constructed from the fourth and first letters of each color to ensure uniqueness. Output is implicit.



              -4 bytes thanks to Shaggy.
              -2 bytes thanks to mazzy.
              A whopping -30 bytes thanks to KGlasier.






              share|improve this answer























              • I don't know if you could do this efficiently (byte-wise), but if you sort by length 3 substrings and then sort with secondary key of the original string, the only collision is green grey which is in the right alphabetical order.
                – HyperNeutrino
                Dec 19 '18 at 17:09






              • 2




                @Shaggy Yes, that works because .IndexOf() will return -1 if the string isn't found, which sorts red into the right ordering. Thanks!
                – AdmBorkBork
                Dec 19 '18 at 17:13










              • i think you can remove brackets around a string.
                – mazzy
                Dec 19 '18 at 18:22










              • @mazzy Indeed, thanks!
                – AdmBorkBork
                Dec 19 '18 at 18:39






              • 1




                @KGlasier Wow, thanks for finding that string! That saves a lot of bytes.
                – AdmBorkBork
                Dec 20 '18 at 13:37














              9












              9








              9







              PowerShell, 262 155 151 127 125 95 bytes





              $args|sort{"rlyegwbrscbrocpyrvo lvnfaldgccvmacmcvseraolsrygpptwkpnoeb".indexof((-join$_[3,0]))}


              Try it online!



              Naive approach. PowerShell sort-object can sort based on a script block that gets executed for every object. Here we're simply getting the .IndexOf() the color from a string, which will assign a numerical value to each color, and then sorts based on those numbers. The string is constructed from the fourth and first letters of each color to ensure uniqueness. Output is implicit.



              -4 bytes thanks to Shaggy.
              -2 bytes thanks to mazzy.
              A whopping -30 bytes thanks to KGlasier.






              share|improve this answer















              PowerShell, 262 155 151 127 125 95 bytes





              $args|sort{"rlyegwbrscbrocpyrvo lvnfaldgccvmacmcvseraolsrygpptwkpnoeb".indexof((-join$_[3,0]))}


              Try it online!



              Naive approach. PowerShell sort-object can sort based on a script block that gets executed for every object. Here we're simply getting the .IndexOf() the color from a string, which will assign a numerical value to each color, and then sorts based on those numbers. The string is constructed from the fourth and first letters of each color to ensure uniqueness. Output is implicit.



              -4 bytes thanks to Shaggy.
              -2 bytes thanks to mazzy.
              A whopping -30 bytes thanks to KGlasier.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Dec 20 '18 at 13:36

























              answered Dec 19 '18 at 16:39









              AdmBorkBork

              26.3k364228




              26.3k364228












              • I don't know if you could do this efficiently (byte-wise), but if you sort by length 3 substrings and then sort with secondary key of the original string, the only collision is green grey which is in the right alphabetical order.
                – HyperNeutrino
                Dec 19 '18 at 17:09






              • 2




                @Shaggy Yes, that works because .IndexOf() will return -1 if the string isn't found, which sorts red into the right ordering. Thanks!
                – AdmBorkBork
                Dec 19 '18 at 17:13










              • i think you can remove brackets around a string.
                – mazzy
                Dec 19 '18 at 18:22










              • @mazzy Indeed, thanks!
                – AdmBorkBork
                Dec 19 '18 at 18:39






              • 1




                @KGlasier Wow, thanks for finding that string! That saves a lot of bytes.
                – AdmBorkBork
                Dec 20 '18 at 13:37


















              • I don't know if you could do this efficiently (byte-wise), but if you sort by length 3 substrings and then sort with secondary key of the original string, the only collision is green grey which is in the right alphabetical order.
                – HyperNeutrino
                Dec 19 '18 at 17:09






              • 2




                @Shaggy Yes, that works because .IndexOf() will return -1 if the string isn't found, which sorts red into the right ordering. Thanks!
                – AdmBorkBork
                Dec 19 '18 at 17:13










              • i think you can remove brackets around a string.
                – mazzy
                Dec 19 '18 at 18:22










              • @mazzy Indeed, thanks!
                – AdmBorkBork
                Dec 19 '18 at 18:39






              • 1




                @KGlasier Wow, thanks for finding that string! That saves a lot of bytes.
                – AdmBorkBork
                Dec 20 '18 at 13:37
















              I don't know if you could do this efficiently (byte-wise), but if you sort by length 3 substrings and then sort with secondary key of the original string, the only collision is green grey which is in the right alphabetical order.
              – HyperNeutrino
              Dec 19 '18 at 17:09




              I don't know if you could do this efficiently (byte-wise), but if you sort by length 3 substrings and then sort with secondary key of the original string, the only collision is green grey which is in the right alphabetical order.
              – HyperNeutrino
              Dec 19 '18 at 17:09




              2




              2




              @Shaggy Yes, that works because .IndexOf() will return -1 if the string isn't found, which sorts red into the right ordering. Thanks!
              – AdmBorkBork
              Dec 19 '18 at 17:13




              @Shaggy Yes, that works because .IndexOf() will return -1 if the string isn't found, which sorts red into the right ordering. Thanks!
              – AdmBorkBork
              Dec 19 '18 at 17:13












              i think you can remove brackets around a string.
              – mazzy
              Dec 19 '18 at 18:22




              i think you can remove brackets around a string.
              – mazzy
              Dec 19 '18 at 18:22












              @mazzy Indeed, thanks!
              – AdmBorkBork
              Dec 19 '18 at 18:39




              @mazzy Indeed, thanks!
              – AdmBorkBork
              Dec 19 '18 at 18:39




              1




              1




              @KGlasier Wow, thanks for finding that string! That saves a lot of bytes.
              – AdmBorkBork
              Dec 20 '18 at 13:37




              @KGlasier Wow, thanks for finding that string! That saves a lot of bytes.
              – AdmBorkBork
              Dec 20 '18 at 13:37











              8















              JavaScript (SpiderMonkey),  106 105  104 bytes



              "When in doubt, just hash the bloody input."





              a=>a.sort((a,b)=>(g=s=>'i0008bar5dj60007f3001p09mseqg0hk40cnl2o'[parseInt(s,36)*50%257%170%40])(a)>g(b))


              Try it online!






              share|improve this answer























              • I've seen (and been impressed by) hash-based solutions like this before. Is there an explanation anywhere for how the magic string/multiplier/mod values are generated? Is it just brute force until you find a set of values that gives a unique output for each of the possible color inputs, or is there a more clever approach?
                – Jack Brounstein
                Dec 19 '18 at 19:03






              • 1




                @JackBrounstein This one was just a quick and dirty brute force search trying random values and minimizing only the maximum output (after the last modulo), without taking the length of the full chain into account (e.g. %99%55 is not better than %123%55 with this approach). So it's certainly sub-optimal. I may try something slightly more sophisticated later, though.
                – Arnauld
                Dec 19 '18 at 19:09
















              8















              JavaScript (SpiderMonkey),  106 105  104 bytes



              "When in doubt, just hash the bloody input."





              a=>a.sort((a,b)=>(g=s=>'i0008bar5dj60007f3001p09mseqg0hk40cnl2o'[parseInt(s,36)*50%257%170%40])(a)>g(b))


              Try it online!






              share|improve this answer























              • I've seen (and been impressed by) hash-based solutions like this before. Is there an explanation anywhere for how the magic string/multiplier/mod values are generated? Is it just brute force until you find a set of values that gives a unique output for each of the possible color inputs, or is there a more clever approach?
                – Jack Brounstein
                Dec 19 '18 at 19:03






              • 1




                @JackBrounstein This one was just a quick and dirty brute force search trying random values and minimizing only the maximum output (after the last modulo), without taking the length of the full chain into account (e.g. %99%55 is not better than %123%55 with this approach). So it's certainly sub-optimal. I may try something slightly more sophisticated later, though.
                – Arnauld
                Dec 19 '18 at 19:09














              8












              8








              8







              JavaScript (SpiderMonkey),  106 105  104 bytes



              "When in doubt, just hash the bloody input."





              a=>a.sort((a,b)=>(g=s=>'i0008bar5dj60007f3001p09mseqg0hk40cnl2o'[parseInt(s,36)*50%257%170%40])(a)>g(b))


              Try it online!






              share|improve this answer















              JavaScript (SpiderMonkey),  106 105  104 bytes



              "When in doubt, just hash the bloody input."





              a=>a.sort((a,b)=>(g=s=>'i0008bar5dj60007f3001p09mseqg0hk40cnl2o'[parseInt(s,36)*50%257%170%40])(a)>g(b))


              Try it online!







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Dec 19 '18 at 23:24

























              answered Dec 19 '18 at 17:14









              Arnauld

              72.4k689305




              72.4k689305












              • I've seen (and been impressed by) hash-based solutions like this before. Is there an explanation anywhere for how the magic string/multiplier/mod values are generated? Is it just brute force until you find a set of values that gives a unique output for each of the possible color inputs, or is there a more clever approach?
                – Jack Brounstein
                Dec 19 '18 at 19:03






              • 1




                @JackBrounstein This one was just a quick and dirty brute force search trying random values and minimizing only the maximum output (after the last modulo), without taking the length of the full chain into account (e.g. %99%55 is not better than %123%55 with this approach). So it's certainly sub-optimal. I may try something slightly more sophisticated later, though.
                – Arnauld
                Dec 19 '18 at 19:09


















              • I've seen (and been impressed by) hash-based solutions like this before. Is there an explanation anywhere for how the magic string/multiplier/mod values are generated? Is it just brute force until you find a set of values that gives a unique output for each of the possible color inputs, or is there a more clever approach?
                – Jack Brounstein
                Dec 19 '18 at 19:03






              • 1




                @JackBrounstein This one was just a quick and dirty brute force search trying random values and minimizing only the maximum output (after the last modulo), without taking the length of the full chain into account (e.g. %99%55 is not better than %123%55 with this approach). So it's certainly sub-optimal. I may try something slightly more sophisticated later, though.
                – Arnauld
                Dec 19 '18 at 19:09
















              I've seen (and been impressed by) hash-based solutions like this before. Is there an explanation anywhere for how the magic string/multiplier/mod values are generated? Is it just brute force until you find a set of values that gives a unique output for each of the possible color inputs, or is there a more clever approach?
              – Jack Brounstein
              Dec 19 '18 at 19:03




              I've seen (and been impressed by) hash-based solutions like this before. Is there an explanation anywhere for how the magic string/multiplier/mod values are generated? Is it just brute force until you find a set of values that gives a unique output for each of the possible color inputs, or is there a more clever approach?
              – Jack Brounstein
              Dec 19 '18 at 19:03




              1




              1




              @JackBrounstein This one was just a quick and dirty brute force search trying random values and minimizing only the maximum output (after the last modulo), without taking the length of the full chain into account (e.g. %99%55 is not better than %123%55 with this approach). So it's certainly sub-optimal. I may try something slightly more sophisticated later, though.
              – Arnauld
              Dec 19 '18 at 19:09




              @JackBrounstein This one was just a quick and dirty brute force search trying random values and minimizing only the maximum output (after the last modulo), without taking the length of the full chain into account (e.g. %99%55 is not better than %123%55 with this approach). So it's certainly sub-optimal. I may try something slightly more sophisticated later, though.
              – Arnauld
              Dec 19 '18 at 19:09











              5















              Jelly, 28 bytes



              “½Ṗ©cƘʂẒẹMMỤẓHP’Œ?“ðÑþQ’,ḥµÞ


              Try it online!



              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.



              “½Ṗ©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





              share|improve this answer



















              • 1




                353690280752 hashes the 29 colors in 29 buckets, but takes one more byte to encode. Using uppercase (332849952364) or titlecase (862442225888) also comes out at 28 bytes.
                – Dennis
                Dec 20 '18 at 2:24
















              5















              Jelly, 28 bytes



              “½Ṗ©cƘʂẒẹMMỤẓHP’Œ?“ðÑþQ’,ḥµÞ


              Try it online!



              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.



              “½Ṗ©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





              share|improve this answer



















              • 1




                353690280752 hashes the 29 colors in 29 buckets, but takes one more byte to encode. Using uppercase (332849952364) or titlecase (862442225888) also comes out at 28 bytes.
                – Dennis
                Dec 20 '18 at 2:24














              5












              5








              5







              Jelly, 28 bytes



              “½Ṗ©cƘʂẒẹMMỤẓHP’Œ?“ðÑþQ’,ḥµÞ


              Try it online!



              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.



              “½Ṗ©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





              share|improve this answer















              Jelly, 28 bytes



              “½Ṗ©cƘʂẒẹMMỤẓHP’Œ?“ðÑþQ’,ḥµÞ


              Try it online!



              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.



              “½Ṗ©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






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Dec 19 '18 at 22:35

























              answered Dec 19 '18 at 22:28









              Dennis

              186k32296735




              186k32296735








              • 1




                353690280752 hashes the 29 colors in 29 buckets, but takes one more byte to encode. Using uppercase (332849952364) or titlecase (862442225888) also comes out at 28 bytes.
                – Dennis
                Dec 20 '18 at 2:24














              • 1




                353690280752 hashes the 29 colors in 29 buckets, but takes one more byte to encode. Using uppercase (332849952364) or titlecase (862442225888) also comes out at 28 bytes.
                – Dennis
                Dec 20 '18 at 2:24








              1




              1




              353690280752 hashes the 29 colors in 29 buckets, but takes one more byte to encode. Using uppercase (332849952364) or titlecase (862442225888) also comes out at 28 bytes.
              – Dennis
              Dec 20 '18 at 2:24




              353690280752 hashes the 29 colors in 29 buckets, but takes one more byte to encode. Using uppercase (332849952364) or titlecase (862442225888) also comes out at 28 bytes.
              – Dennis
              Dec 20 '18 at 2:24











              4















              Python 3, 93 bytes





              lambda r:sorted(r,key=lambda s:'iV^ZzwnFM@pYuOobXGAKyf[tUR]E'.find(chr(int(s,36)%127%60+64)))


              Try it online!



              Reads each color as a base-36 int. Brute-forced the moduli and chose an arbitrary offset among the 19 that didn't require escapes.






              share|improve this answer


























                4















                Python 3, 93 bytes





                lambda r:sorted(r,key=lambda s:'iV^ZzwnFM@pYuOobXGAKyf[tUR]E'.find(chr(int(s,36)%127%60+64)))


                Try it online!



                Reads each color as a base-36 int. Brute-forced the moduli and chose an arbitrary offset among the 19 that didn't require escapes.






                share|improve this answer
























                  4












                  4








                  4







                  Python 3, 93 bytes





                  lambda r:sorted(r,key=lambda s:'iV^ZzwnFM@pYuOobXGAKyf[tUR]E'.find(chr(int(s,36)%127%60+64)))


                  Try it online!



                  Reads each color as a base-36 int. Brute-forced the moduli and chose an arbitrary offset among the 19 that didn't require escapes.






                  share|improve this answer













                  Python 3, 93 bytes





                  lambda r:sorted(r,key=lambda s:'iV^ZzwnFM@pYuOobXGAKyf[tUR]E'.find(chr(int(s,36)%127%60+64)))


                  Try it online!



                  Reads each color as a base-36 int. Brute-forced the moduli and chose an arbitrary offset among the 19 that didn't require escapes.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 20 '18 at 6:51









                  attinat

                  1014




                  1014























                      3














                      I will improve the string compression in a while




                      Japt, 88 78 71 bytes



                      ñ@`䊐âwrÒ.cÖ¨acru½ivo¤faØngoÒqauvœamsolv€osz¨e¶s gœrpl–tpˆ„g½u`bXé4 ¯3


                      Try it online!






                      share|improve this answer























                      • A quick port of one of the other solutions here comes in at 46 bytes, if you want to try for it.
                        – Shaggy
                        Dec 20 '18 at 13:34
















                      3














                      I will improve the string compression in a while




                      Japt, 88 78 71 bytes



                      ñ@`䊐âwrÒ.cÖ¨acru½ivo¤faØngoÒqauvœamsolv€osz¨e¶s gœrpl–tpˆ„g½u`bXé4 ¯3


                      Try it online!






                      share|improve this answer























                      • A quick port of one of the other solutions here comes in at 46 bytes, if you want to try for it.
                        – Shaggy
                        Dec 20 '18 at 13:34














                      3












                      3








                      3






                      I will improve the string compression in a while




                      Japt, 88 78 71 bytes



                      ñ@`䊐âwrÒ.cÖ¨acru½ivo¤faØngoÒqauvœamsolv€osz¨e¶s gœrpl–tpˆ„g½u`bXé4 ¯3


                      Try it online!






                      share|improve this answer














                      I will improve the string compression in a while




                      Japt, 88 78 71 bytes



                      ñ@`䊐âwrÒ.cÖ¨acru½ivo¤faØngoÒqauvœamsolv€osz¨e¶s gœrpl–tpˆ„g½u`bXé4 ¯3


                      Try it online!







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Dec 19 '18 at 20:25

























                      answered Dec 19 '18 at 17:34









                      Luis felipe De jesus Munoz

                      4,08421254




                      4,08421254












                      • A quick port of one of the other solutions here comes in at 46 bytes, if you want to try for it.
                        – Shaggy
                        Dec 20 '18 at 13:34


















                      • A quick port of one of the other solutions here comes in at 46 bytes, if you want to try for it.
                        – Shaggy
                        Dec 20 '18 at 13:34
















                      A quick port of one of the other solutions here comes in at 46 bytes, if you want to try for it.
                      – Shaggy
                      Dec 20 '18 at 13:34




                      A quick port of one of the other solutions here comes in at 46 bytes, if you want to try for it.
                      – Shaggy
                      Dec 20 '18 at 13:34











                      3














                      Wolfram Language 255 213 199 bytes



                      Fourteen bytes saved by Dennis, who avoided the " marks, using symbols instead of strings.



                      SortBy[#,{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}~Position~#&]&


                      Try It Online!






                      share|improve this answer




























                        3














                        Wolfram Language 255 213 199 bytes



                        Fourteen bytes saved by Dennis, who avoided the " marks, using symbols instead of strings.



                        SortBy[#,{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}~Position~#&]&


                        Try It Online!






                        share|improve this answer


























                          3












                          3








                          3






                          Wolfram Language 255 213 199 bytes



                          Fourteen bytes saved by Dennis, who avoided the " marks, using symbols instead of strings.



                          SortBy[#,{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}~Position~#&]&


                          Try It Online!






                          share|improve this answer














                          Wolfram Language 255 213 199 bytes



                          Fourteen bytes saved by Dennis, who avoided the " marks, using symbols instead of strings.



                          SortBy[#,{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}~Position~#&]&


                          Try It Online!







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Dec 20 '18 at 13:58

























                          answered Dec 19 '18 at 17:10









                          DavidC

                          23.8k243102




                          23.8k243102























                              3














                              Powershell, 124 120 124 119 118 102 bytes





                              $args|sort{$c=$_
                              'bluOrPiWPuG*yRusLeARoSiCriCrMCGoLFVOlRuPOBlSBGYR'-csplit'(?=[A-Z])'|%{$c-like"$_*"}}


                              Try It Online!



                              Explanation:




                              1. The data string contains the first significant letters of the color labels in descending order. Except for the Grey label - G*y is shorter.


                              2. -csplit'(?=[A-Z])' splits the data string to the array (blu,Or,Pi,W,Pu,G*y,Rus,Le,A,Ro,Si,Cri,Cr,M,C,Go,L,F,V,Ol,Ru,P,O,Bl,S,B,G,Y,R)


                              3. |%{$c-like"$_*"} maps the string array to the array of boolean. Where True means "a color label starts from this string" (like is case-insensitive operator, csplit - case-sensitive. see doc).


                              4. sort{} sorts a color lables by the arrays of boolean in ascending order.



                              The sorting by array is a very interesting feature in the Powershell. In this script all arrays have the same length and contain Boolean values only. This sorting is performed in the lexographic order of boolean arrays.



                              Therefore, the string can contain one-letter abbreviations for the last labels. If there is a match at the beginning of the array, the matches at the end have no effect.





                                     blu Or Pi W Pu G*y Rus Le A Ro Si Cri Cr M C Go L F V Ol Ru P O Bl S B G Y R
                              green: - - - - - - - - - - - - - - - - - - - - - - - - - - T - -
                              gold : - - - - - - - - - - - - - - - T - - - - - - - - - - T - -
                              grey : - - - - - T - - - - - - - - - - - - - - - - - - - - T - -

                              : green < gold < grey


                              Where T is true and - is false.





                              Test script:





                              $f = {

                              $args|sort{$c=$_
                              'bluOrPiWPuG*yRusLeARoSiCriCrMCGoLFVOlRuPOBlSBGYR'-csplit'(?=[A-Z])'|%{$c-like"$_*"}}

                              }

                              @(
                              ,( @(), @() )
                              ,( ('green', 'blue', 'red', 'brown'), ('red', 'green', 'brown', 'blue') )
                              ,( ("gold", "grey", "green"), ("green", "gold", "grey") )
                              ,( ("ruby","yellow","red","grey"), ("red", "yellow", "ruby", "grey") )
                              ,( ("gold", "green", "fawn", "white", "azure", "rose", "black", "purple", "orange", "silver", "ruby", "blue", "lilac", "crimson", "pink", "cream", "lemon", "russet", "grey", "olive", "violet", "mauve", "chocolate", "yellow", "peach", "brown", "ochre", "scarlet", "red"),
                              ("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") )
                              ) | % {
                              $inp,$expected = $_
                              $result = &$f @inp # splatting
                              "$("$result"-eq"$expected"): $result"
                              }


                              Output:



                              True:
                              True: red green brown blue
                              True: green gold grey
                              True: red yellow ruby grey
                              True: 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





                              share|improve this answer























                              • I have This site can’t be reached error. Sorry.
                                – mazzy
                                Dec 19 '18 at 22:16






                              • 1




                                Added a revised TIO for you.
                                – Shaggy
                                Dec 20 '18 at 17:02
















                              3














                              Powershell, 124 120 124 119 118 102 bytes





                              $args|sort{$c=$_
                              'bluOrPiWPuG*yRusLeARoSiCriCrMCGoLFVOlRuPOBlSBGYR'-csplit'(?=[A-Z])'|%{$c-like"$_*"}}


                              Try It Online!



                              Explanation:




                              1. The data string contains the first significant letters of the color labels in descending order. Except for the Grey label - G*y is shorter.


                              2. -csplit'(?=[A-Z])' splits the data string to the array (blu,Or,Pi,W,Pu,G*y,Rus,Le,A,Ro,Si,Cri,Cr,M,C,Go,L,F,V,Ol,Ru,P,O,Bl,S,B,G,Y,R)


                              3. |%{$c-like"$_*"} maps the string array to the array of boolean. Where True means "a color label starts from this string" (like is case-insensitive operator, csplit - case-sensitive. see doc).


                              4. sort{} sorts a color lables by the arrays of boolean in ascending order.



                              The sorting by array is a very interesting feature in the Powershell. In this script all arrays have the same length and contain Boolean values only. This sorting is performed in the lexographic order of boolean arrays.



                              Therefore, the string can contain one-letter abbreviations for the last labels. If there is a match at the beginning of the array, the matches at the end have no effect.





                                     blu Or Pi W Pu G*y Rus Le A Ro Si Cri Cr M C Go L F V Ol Ru P O Bl S B G Y R
                              green: - - - - - - - - - - - - - - - - - - - - - - - - - - T - -
                              gold : - - - - - - - - - - - - - - - T - - - - - - - - - - T - -
                              grey : - - - - - T - - - - - - - - - - - - - - - - - - - - T - -

                              : green < gold < grey


                              Where T is true and - is false.





                              Test script:





                              $f = {

                              $args|sort{$c=$_
                              'bluOrPiWPuG*yRusLeARoSiCriCrMCGoLFVOlRuPOBlSBGYR'-csplit'(?=[A-Z])'|%{$c-like"$_*"}}

                              }

                              @(
                              ,( @(), @() )
                              ,( ('green', 'blue', 'red', 'brown'), ('red', 'green', 'brown', 'blue') )
                              ,( ("gold", "grey", "green"), ("green", "gold", "grey") )
                              ,( ("ruby","yellow","red","grey"), ("red", "yellow", "ruby", "grey") )
                              ,( ("gold", "green", "fawn", "white", "azure", "rose", "black", "purple", "orange", "silver", "ruby", "blue", "lilac", "crimson", "pink", "cream", "lemon", "russet", "grey", "olive", "violet", "mauve", "chocolate", "yellow", "peach", "brown", "ochre", "scarlet", "red"),
                              ("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") )
                              ) | % {
                              $inp,$expected = $_
                              $result = &$f @inp # splatting
                              "$("$result"-eq"$expected"): $result"
                              }


                              Output:



                              True:
                              True: red green brown blue
                              True: green gold grey
                              True: red yellow ruby grey
                              True: 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





                              share|improve this answer























                              • I have This site can’t be reached error. Sorry.
                                – mazzy
                                Dec 19 '18 at 22:16






                              • 1




                                Added a revised TIO for you.
                                – Shaggy
                                Dec 20 '18 at 17:02














                              3












                              3








                              3






                              Powershell, 124 120 124 119 118 102 bytes





                              $args|sort{$c=$_
                              'bluOrPiWPuG*yRusLeARoSiCriCrMCGoLFVOlRuPOBlSBGYR'-csplit'(?=[A-Z])'|%{$c-like"$_*"}}


                              Try It Online!



                              Explanation:




                              1. The data string contains the first significant letters of the color labels in descending order. Except for the Grey label - G*y is shorter.


                              2. -csplit'(?=[A-Z])' splits the data string to the array (blu,Or,Pi,W,Pu,G*y,Rus,Le,A,Ro,Si,Cri,Cr,M,C,Go,L,F,V,Ol,Ru,P,O,Bl,S,B,G,Y,R)


                              3. |%{$c-like"$_*"} maps the string array to the array of boolean. Where True means "a color label starts from this string" (like is case-insensitive operator, csplit - case-sensitive. see doc).


                              4. sort{} sorts a color lables by the arrays of boolean in ascending order.



                              The sorting by array is a very interesting feature in the Powershell. In this script all arrays have the same length and contain Boolean values only. This sorting is performed in the lexographic order of boolean arrays.



                              Therefore, the string can contain one-letter abbreviations for the last labels. If there is a match at the beginning of the array, the matches at the end have no effect.





                                     blu Or Pi W Pu G*y Rus Le A Ro Si Cri Cr M C Go L F V Ol Ru P O Bl S B G Y R
                              green: - - - - - - - - - - - - - - - - - - - - - - - - - - T - -
                              gold : - - - - - - - - - - - - - - - T - - - - - - - - - - T - -
                              grey : - - - - - T - - - - - - - - - - - - - - - - - - - - T - -

                              : green < gold < grey


                              Where T is true and - is false.





                              Test script:





                              $f = {

                              $args|sort{$c=$_
                              'bluOrPiWPuG*yRusLeARoSiCriCrMCGoLFVOlRuPOBlSBGYR'-csplit'(?=[A-Z])'|%{$c-like"$_*"}}

                              }

                              @(
                              ,( @(), @() )
                              ,( ('green', 'blue', 'red', 'brown'), ('red', 'green', 'brown', 'blue') )
                              ,( ("gold", "grey", "green"), ("green", "gold", "grey") )
                              ,( ("ruby","yellow","red","grey"), ("red", "yellow", "ruby", "grey") )
                              ,( ("gold", "green", "fawn", "white", "azure", "rose", "black", "purple", "orange", "silver", "ruby", "blue", "lilac", "crimson", "pink", "cream", "lemon", "russet", "grey", "olive", "violet", "mauve", "chocolate", "yellow", "peach", "brown", "ochre", "scarlet", "red"),
                              ("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") )
                              ) | % {
                              $inp,$expected = $_
                              $result = &$f @inp # splatting
                              "$("$result"-eq"$expected"): $result"
                              }


                              Output:



                              True:
                              True: red green brown blue
                              True: green gold grey
                              True: red yellow ruby grey
                              True: 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





                              share|improve this answer














                              Powershell, 124 120 124 119 118 102 bytes





                              $args|sort{$c=$_
                              'bluOrPiWPuG*yRusLeARoSiCriCrMCGoLFVOlRuPOBlSBGYR'-csplit'(?=[A-Z])'|%{$c-like"$_*"}}


                              Try It Online!



                              Explanation:




                              1. The data string contains the first significant letters of the color labels in descending order. Except for the Grey label - G*y is shorter.


                              2. -csplit'(?=[A-Z])' splits the data string to the array (blu,Or,Pi,W,Pu,G*y,Rus,Le,A,Ro,Si,Cri,Cr,M,C,Go,L,F,V,Ol,Ru,P,O,Bl,S,B,G,Y,R)


                              3. |%{$c-like"$_*"} maps the string array to the array of boolean. Where True means "a color label starts from this string" (like is case-insensitive operator, csplit - case-sensitive. see doc).


                              4. sort{} sorts a color lables by the arrays of boolean in ascending order.



                              The sorting by array is a very interesting feature in the Powershell. In this script all arrays have the same length and contain Boolean values only. This sorting is performed in the lexographic order of boolean arrays.



                              Therefore, the string can contain one-letter abbreviations for the last labels. If there is a match at the beginning of the array, the matches at the end have no effect.





                                     blu Or Pi W Pu G*y Rus Le A Ro Si Cri Cr M C Go L F V Ol Ru P O Bl S B G Y R
                              green: - - - - - - - - - - - - - - - - - - - - - - - - - - T - -
                              gold : - - - - - - - - - - - - - - - T - - - - - - - - - - T - -
                              grey : - - - - - T - - - - - - - - - - - - - - - - - - - - T - -

                              : green < gold < grey


                              Where T is true and - is false.





                              Test script:





                              $f = {

                              $args|sort{$c=$_
                              'bluOrPiWPuG*yRusLeARoSiCriCrMCGoLFVOlRuPOBlSBGYR'-csplit'(?=[A-Z])'|%{$c-like"$_*"}}

                              }

                              @(
                              ,( @(), @() )
                              ,( ('green', 'blue', 'red', 'brown'), ('red', 'green', 'brown', 'blue') )
                              ,( ("gold", "grey", "green"), ("green", "gold", "grey") )
                              ,( ("ruby","yellow","red","grey"), ("red", "yellow", "ruby", "grey") )
                              ,( ("gold", "green", "fawn", "white", "azure", "rose", "black", "purple", "orange", "silver", "ruby", "blue", "lilac", "crimson", "pink", "cream", "lemon", "russet", "grey", "olive", "violet", "mauve", "chocolate", "yellow", "peach", "brown", "ochre", "scarlet", "red"),
                              ("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") )
                              ) | % {
                              $inp,$expected = $_
                              $result = &$f @inp # splatting
                              "$("$result"-eq"$expected"): $result"
                              }


                              Output:



                              True:
                              True: red green brown blue
                              True: green gold grey
                              True: red yellow ruby grey
                              True: 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






                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Dec 20 '18 at 17:01









                              Shaggy

                              18.9k21666




                              18.9k21666










                              answered Dec 19 '18 at 18:15









                              mazzy

                              2,1151315




                              2,1151315












                              • I have This site can’t be reached error. Sorry.
                                – mazzy
                                Dec 19 '18 at 22:16






                              • 1




                                Added a revised TIO for you.
                                – Shaggy
                                Dec 20 '18 at 17:02


















                              • I have This site can’t be reached error. Sorry.
                                – mazzy
                                Dec 19 '18 at 22:16






                              • 1




                                Added a revised TIO for you.
                                – Shaggy
                                Dec 20 '18 at 17:02
















                              I have This site can’t be reached error. Sorry.
                              – mazzy
                              Dec 19 '18 at 22:16




                              I have This site can’t be reached error. Sorry.
                              – mazzy
                              Dec 19 '18 at 22:16




                              1




                              1




                              Added a revised TIO for you.
                              – Shaggy
                              Dec 20 '18 at 17:02




                              Added a revised TIO for you.
                              – Shaggy
                              Dec 20 '18 at 17:02











                              2















                              Python 2, 186 bytes





                              lambda a:[y for x,y in sorted((max(" y gree br sc bla oc pe rub ol v f li go ch m cre cri si ro a le rus grey pu w pi or blu ".find(" %s "%c[:i+1])for i,j in enumerate(c)),c)for c in a)]


                              Try it online!



                              Finds all matches for progressive character substrings (Ex: "green" will check for "g", "gr", "gre", "gree", and "green") in the identifier string, and keeps the maximum index. "red" is always first, anf find() returns -1 for missing matches, so there is no identifier for red specifically.



                              Once the colors are turned into (index, color) pairs, sorts array on first item of pair and then discards first item of each pair.






                              share|improve this answer


























                                2















                                Python 2, 186 bytes





                                lambda a:[y for x,y in sorted((max(" y gree br sc bla oc pe rub ol v f li go ch m cre cri si ro a le rus grey pu w pi or blu ".find(" %s "%c[:i+1])for i,j in enumerate(c)),c)for c in a)]


                                Try it online!



                                Finds all matches for progressive character substrings (Ex: "green" will check for "g", "gr", "gre", "gree", and "green") in the identifier string, and keeps the maximum index. "red" is always first, anf find() returns -1 for missing matches, so there is no identifier for red specifically.



                                Once the colors are turned into (index, color) pairs, sorts array on first item of pair and then discards first item of each pair.






                                share|improve this answer
























                                  2












                                  2








                                  2







                                  Python 2, 186 bytes





                                  lambda a:[y for x,y in sorted((max(" y gree br sc bla oc pe rub ol v f li go ch m cre cri si ro a le rus grey pu w pi or blu ".find(" %s "%c[:i+1])for i,j in enumerate(c)),c)for c in a)]


                                  Try it online!



                                  Finds all matches for progressive character substrings (Ex: "green" will check for "g", "gr", "gre", "gree", and "green") in the identifier string, and keeps the maximum index. "red" is always first, anf find() returns -1 for missing matches, so there is no identifier for red specifically.



                                  Once the colors are turned into (index, color) pairs, sorts array on first item of pair and then discards first item of each pair.






                                  share|improve this answer













                                  Python 2, 186 bytes





                                  lambda a:[y for x,y in sorted((max(" y gree br sc bla oc pe rub ol v f li go ch m cre cri si ro a le rus grey pu w pi or blu ".find(" %s "%c[:i+1])for i,j in enumerate(c)),c)for c in a)]


                                  Try it online!



                                  Finds all matches for progressive character substrings (Ex: "green" will check for "g", "gr", "gre", "gree", and "green") in the identifier string, and keeps the maximum index. "red" is always first, anf find() returns -1 for missing matches, so there is no identifier for red specifically.



                                  Once the colors are turned into (index, color) pairs, sorts array on first item of pair and then discards first item of each pair.







                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Dec 19 '18 at 21:44









                                  Triggernometry

                                  56517




                                  56517























                                      2















                                      C# (Visual C# Interactive Compiler), 321 219 210 161 159 138 bytes





                                      n=>n.OrderBy(a=>a!="grey"?"yelgrebroscablaochperuboliviofawlilgolchomaucrecrisilrosazulemruspurwhipinorablu".IndexOf(a.Substring(0,3)):65)


                                      Try it online!



                                      -3 bytes thanks to Shaggy, -18 thanks to TheLethalCoder



                                      Takes input as a List<string>, returns an IOrderedEnumerable<string>



                                      How this works is that it orders the list by each string's index in the original string. The original string has every color except for grey turned to it's first three letters. Grey is not there, since green and grey would cause ambiguity. Red isn't there either, since IndexOf returns -1 if the string doesn't appear.






                                      share|improve this answer























                                      • I think you can remove red from your lookup string and replace 68 with 65 to save 3 bytes. On my phone so haven't fully tested it.
                                        – Shaggy
                                        Dec 20 '18 at 8:16










                                      • You can use the string inline with an implicit return for 142 bytes n=>n.OrderBy(a=>a!="grey"?"redyelgrebroscablaochperuboliviofawlilgolchomaucrecrisilrosazulemruspurwhipinorablu".IndexOf(a.Substring(0,3)):68); However, you need to include the usings in your byte count as they are required to run. You can use the namespace trick to shorten the count required though.
                                        – TheLethalCoder
                                        Dec 20 '18 at 11:51










                                      • If I use the namespace trick, do I have to add the namespace to my number of bytes?
                                        – Embodiment of Ignorance
                                        Dec 20 '18 at 16:34










                                      • I can just change the compiler to Visual C# Interactive Compiler, and then I won't have to add the usings
                                        – Embodiment of Ignorance
                                        Dec 20 '18 at 16:44










                                      • Ah good idea on changing to Interactive but yes if you did the namespace trick you'd have to include it in your byte count. Essentially adding namespace System.Linq{} or whatever you would have chosen.
                                        – TheLethalCoder
                                        Dec 20 '18 at 17:13
















                                      2















                                      C# (Visual C# Interactive Compiler), 321 219 210 161 159 138 bytes





                                      n=>n.OrderBy(a=>a!="grey"?"yelgrebroscablaochperuboliviofawlilgolchomaucrecrisilrosazulemruspurwhipinorablu".IndexOf(a.Substring(0,3)):65)


                                      Try it online!



                                      -3 bytes thanks to Shaggy, -18 thanks to TheLethalCoder



                                      Takes input as a List<string>, returns an IOrderedEnumerable<string>



                                      How this works is that it orders the list by each string's index in the original string. The original string has every color except for grey turned to it's first three letters. Grey is not there, since green and grey would cause ambiguity. Red isn't there either, since IndexOf returns -1 if the string doesn't appear.






                                      share|improve this answer























                                      • I think you can remove red from your lookup string and replace 68 with 65 to save 3 bytes. On my phone so haven't fully tested it.
                                        – Shaggy
                                        Dec 20 '18 at 8:16










                                      • You can use the string inline with an implicit return for 142 bytes n=>n.OrderBy(a=>a!="grey"?"redyelgrebroscablaochperuboliviofawlilgolchomaucrecrisilrosazulemruspurwhipinorablu".IndexOf(a.Substring(0,3)):68); However, you need to include the usings in your byte count as they are required to run. You can use the namespace trick to shorten the count required though.
                                        – TheLethalCoder
                                        Dec 20 '18 at 11:51










                                      • If I use the namespace trick, do I have to add the namespace to my number of bytes?
                                        – Embodiment of Ignorance
                                        Dec 20 '18 at 16:34










                                      • I can just change the compiler to Visual C# Interactive Compiler, and then I won't have to add the usings
                                        – Embodiment of Ignorance
                                        Dec 20 '18 at 16:44










                                      • Ah good idea on changing to Interactive but yes if you did the namespace trick you'd have to include it in your byte count. Essentially adding namespace System.Linq{} or whatever you would have chosen.
                                        – TheLethalCoder
                                        Dec 20 '18 at 17:13














                                      2












                                      2








                                      2







                                      C# (Visual C# Interactive Compiler), 321 219 210 161 159 138 bytes





                                      n=>n.OrderBy(a=>a!="grey"?"yelgrebroscablaochperuboliviofawlilgolchomaucrecrisilrosazulemruspurwhipinorablu".IndexOf(a.Substring(0,3)):65)


                                      Try it online!



                                      -3 bytes thanks to Shaggy, -18 thanks to TheLethalCoder



                                      Takes input as a List<string>, returns an IOrderedEnumerable<string>



                                      How this works is that it orders the list by each string's index in the original string. The original string has every color except for grey turned to it's first three letters. Grey is not there, since green and grey would cause ambiguity. Red isn't there either, since IndexOf returns -1 if the string doesn't appear.






                                      share|improve this answer















                                      C# (Visual C# Interactive Compiler), 321 219 210 161 159 138 bytes





                                      n=>n.OrderBy(a=>a!="grey"?"yelgrebroscablaochperuboliviofawlilgolchomaucrecrisilrosazulemruspurwhipinorablu".IndexOf(a.Substring(0,3)):65)


                                      Try it online!



                                      -3 bytes thanks to Shaggy, -18 thanks to TheLethalCoder



                                      Takes input as a List<string>, returns an IOrderedEnumerable<string>



                                      How this works is that it orders the list by each string's index in the original string. The original string has every color except for grey turned to it's first three letters. Grey is not there, since green and grey would cause ambiguity. Red isn't there either, since IndexOf returns -1 if the string doesn't appear.







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Dec 20 '18 at 17:10

























                                      answered Dec 19 '18 at 19:48









                                      Embodiment of Ignorance

                                      39712




                                      39712












                                      • I think you can remove red from your lookup string and replace 68 with 65 to save 3 bytes. On my phone so haven't fully tested it.
                                        – Shaggy
                                        Dec 20 '18 at 8:16










                                      • You can use the string inline with an implicit return for 142 bytes n=>n.OrderBy(a=>a!="grey"?"redyelgrebroscablaochperuboliviofawlilgolchomaucrecrisilrosazulemruspurwhipinorablu".IndexOf(a.Substring(0,3)):68); However, you need to include the usings in your byte count as they are required to run. You can use the namespace trick to shorten the count required though.
                                        – TheLethalCoder
                                        Dec 20 '18 at 11:51










                                      • If I use the namespace trick, do I have to add the namespace to my number of bytes?
                                        – Embodiment of Ignorance
                                        Dec 20 '18 at 16:34










                                      • I can just change the compiler to Visual C# Interactive Compiler, and then I won't have to add the usings
                                        – Embodiment of Ignorance
                                        Dec 20 '18 at 16:44










                                      • Ah good idea on changing to Interactive but yes if you did the namespace trick you'd have to include it in your byte count. Essentially adding namespace System.Linq{} or whatever you would have chosen.
                                        – TheLethalCoder
                                        Dec 20 '18 at 17:13


















                                      • I think you can remove red from your lookup string and replace 68 with 65 to save 3 bytes. On my phone so haven't fully tested it.
                                        – Shaggy
                                        Dec 20 '18 at 8:16










                                      • You can use the string inline with an implicit return for 142 bytes n=>n.OrderBy(a=>a!="grey"?"redyelgrebroscablaochperuboliviofawlilgolchomaucrecrisilrosazulemruspurwhipinorablu".IndexOf(a.Substring(0,3)):68); However, you need to include the usings in your byte count as they are required to run. You can use the namespace trick to shorten the count required though.
                                        – TheLethalCoder
                                        Dec 20 '18 at 11:51










                                      • If I use the namespace trick, do I have to add the namespace to my number of bytes?
                                        – Embodiment of Ignorance
                                        Dec 20 '18 at 16:34










                                      • I can just change the compiler to Visual C# Interactive Compiler, and then I won't have to add the usings
                                        – Embodiment of Ignorance
                                        Dec 20 '18 at 16:44










                                      • Ah good idea on changing to Interactive but yes if you did the namespace trick you'd have to include it in your byte count. Essentially adding namespace System.Linq{} or whatever you would have chosen.
                                        – TheLethalCoder
                                        Dec 20 '18 at 17:13
















                                      I think you can remove red from your lookup string and replace 68 with 65 to save 3 bytes. On my phone so haven't fully tested it.
                                      – Shaggy
                                      Dec 20 '18 at 8:16




                                      I think you can remove red from your lookup string and replace 68 with 65 to save 3 bytes. On my phone so haven't fully tested it.
                                      – Shaggy
                                      Dec 20 '18 at 8:16












                                      You can use the string inline with an implicit return for 142 bytes n=>n.OrderBy(a=>a!="grey"?"redyelgrebroscablaochperuboliviofawlilgolchomaucrecrisilrosazulemruspurwhipinorablu".IndexOf(a.Substring(0,3)):68); However, you need to include the usings in your byte count as they are required to run. You can use the namespace trick to shorten the count required though.
                                      – TheLethalCoder
                                      Dec 20 '18 at 11:51




                                      You can use the string inline with an implicit return for 142 bytes n=>n.OrderBy(a=>a!="grey"?"redyelgrebroscablaochperuboliviofawlilgolchomaucrecrisilrosazulemruspurwhipinorablu".IndexOf(a.Substring(0,3)):68); However, you need to include the usings in your byte count as they are required to run. You can use the namespace trick to shorten the count required though.
                                      – TheLethalCoder
                                      Dec 20 '18 at 11:51












                                      If I use the namespace trick, do I have to add the namespace to my number of bytes?
                                      – Embodiment of Ignorance
                                      Dec 20 '18 at 16:34




                                      If I use the namespace trick, do I have to add the namespace to my number of bytes?
                                      – Embodiment of Ignorance
                                      Dec 20 '18 at 16:34












                                      I can just change the compiler to Visual C# Interactive Compiler, and then I won't have to add the usings
                                      – Embodiment of Ignorance
                                      Dec 20 '18 at 16:44




                                      I can just change the compiler to Visual C# Interactive Compiler, and then I won't have to add the usings
                                      – Embodiment of Ignorance
                                      Dec 20 '18 at 16:44












                                      Ah good idea on changing to Interactive but yes if you did the namespace trick you'd have to include it in your byte count. Essentially adding namespace System.Linq{} or whatever you would have chosen.
                                      – TheLethalCoder
                                      Dec 20 '18 at 17:13




                                      Ah good idea on changing to Interactive but yes if you did the namespace trick you'd have to include it in your byte count. Essentially adding namespace System.Linq{} or whatever you would have chosen.
                                      – TheLethalCoder
                                      Dec 20 '18 at 17:13











                                      2















                                      Python 3, 130 bytes





                                      lambda*a:sorted(a,key=lambda c:("r,ylgebwsrtbcorpcryovvlfnlagdccamvca cmnsvrearlorsgyppwtpkonbe".find(c[::3]+" "*(c=="cream")),c))


                                      Try it online!






                                      share|improve this answer























                                      • @Shaggy I don't think so? can you give me an input and the intended output
                                        – HyperNeutrino
                                        Dec 19 '18 at 17:19










                                      • @AdmBorkBork Thanks, just realized what Shaggy meant by that. I was only comparing green and grey to each other lol
                                        – HyperNeutrino
                                        Dec 19 '18 at 17:21










                                      • To add to Shaggy and AdmBorkBork's comments, "green" and "grey" both begin with "gre".
                                        – DavidC
                                        Dec 19 '18 at 17:21










                                      • @Shaggy fixed i think
                                        – HyperNeutrino
                                        Dec 19 '18 at 17:23






                                      • 1




                                        @Shaggy Fixed it, thanks. Required a bit of a hack for cream since ca is a substring of cca for chocolate oof.
                                        – HyperNeutrino
                                        Dec 21 '18 at 15:48
















                                      2















                                      Python 3, 130 bytes





                                      lambda*a:sorted(a,key=lambda c:("r,ylgebwsrtbcorpcryovvlfnlagdccamvca cmnsvrearlorsgyppwtpkonbe".find(c[::3]+" "*(c=="cream")),c))


                                      Try it online!






                                      share|improve this answer























                                      • @Shaggy I don't think so? can you give me an input and the intended output
                                        – HyperNeutrino
                                        Dec 19 '18 at 17:19










                                      • @AdmBorkBork Thanks, just realized what Shaggy meant by that. I was only comparing green and grey to each other lol
                                        – HyperNeutrino
                                        Dec 19 '18 at 17:21










                                      • To add to Shaggy and AdmBorkBork's comments, "green" and "grey" both begin with "gre".
                                        – DavidC
                                        Dec 19 '18 at 17:21










                                      • @Shaggy fixed i think
                                        – HyperNeutrino
                                        Dec 19 '18 at 17:23






                                      • 1




                                        @Shaggy Fixed it, thanks. Required a bit of a hack for cream since ca is a substring of cca for chocolate oof.
                                        – HyperNeutrino
                                        Dec 21 '18 at 15:48














                                      2












                                      2








                                      2







                                      Python 3, 130 bytes





                                      lambda*a:sorted(a,key=lambda c:("r,ylgebwsrtbcorpcryovvlfnlagdccamvca cmnsvrearlorsgyppwtpkonbe".find(c[::3]+" "*(c=="cream")),c))


                                      Try it online!






                                      share|improve this answer















                                      Python 3, 130 bytes





                                      lambda*a:sorted(a,key=lambda c:("r,ylgebwsrtbcorpcryovvlfnlagdccamvca cmnsvrearlorsgyppwtpkonbe".find(c[::3]+" "*(c=="cream")),c))


                                      Try it online!







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Dec 21 '18 at 15:48

























                                      answered Dec 19 '18 at 17:02









                                      HyperNeutrino

                                      18.8k437147




                                      18.8k437147












                                      • @Shaggy I don't think so? can you give me an input and the intended output
                                        – HyperNeutrino
                                        Dec 19 '18 at 17:19










                                      • @AdmBorkBork Thanks, just realized what Shaggy meant by that. I was only comparing green and grey to each other lol
                                        – HyperNeutrino
                                        Dec 19 '18 at 17:21










                                      • To add to Shaggy and AdmBorkBork's comments, "green" and "grey" both begin with "gre".
                                        – DavidC
                                        Dec 19 '18 at 17:21










                                      • @Shaggy fixed i think
                                        – HyperNeutrino
                                        Dec 19 '18 at 17:23






                                      • 1




                                        @Shaggy Fixed it, thanks. Required a bit of a hack for cream since ca is a substring of cca for chocolate oof.
                                        – HyperNeutrino
                                        Dec 21 '18 at 15:48


















                                      • @Shaggy I don't think so? can you give me an input and the intended output
                                        – HyperNeutrino
                                        Dec 19 '18 at 17:19










                                      • @AdmBorkBork Thanks, just realized what Shaggy meant by that. I was only comparing green and grey to each other lol
                                        – HyperNeutrino
                                        Dec 19 '18 at 17:21










                                      • To add to Shaggy and AdmBorkBork's comments, "green" and "grey" both begin with "gre".
                                        – DavidC
                                        Dec 19 '18 at 17:21










                                      • @Shaggy fixed i think
                                        – HyperNeutrino
                                        Dec 19 '18 at 17:23






                                      • 1




                                        @Shaggy Fixed it, thanks. Required a bit of a hack for cream since ca is a substring of cca for chocolate oof.
                                        – HyperNeutrino
                                        Dec 21 '18 at 15:48
















                                      @Shaggy I don't think so? can you give me an input and the intended output
                                      – HyperNeutrino
                                      Dec 19 '18 at 17:19




                                      @Shaggy I don't think so? can you give me an input and the intended output
                                      – HyperNeutrino
                                      Dec 19 '18 at 17:19












                                      @AdmBorkBork Thanks, just realized what Shaggy meant by that. I was only comparing green and grey to each other lol
                                      – HyperNeutrino
                                      Dec 19 '18 at 17:21




                                      @AdmBorkBork Thanks, just realized what Shaggy meant by that. I was only comparing green and grey to each other lol
                                      – HyperNeutrino
                                      Dec 19 '18 at 17:21












                                      To add to Shaggy and AdmBorkBork's comments, "green" and "grey" both begin with "gre".
                                      – DavidC
                                      Dec 19 '18 at 17:21




                                      To add to Shaggy and AdmBorkBork's comments, "green" and "grey" both begin with "gre".
                                      – DavidC
                                      Dec 19 '18 at 17:21












                                      @Shaggy fixed i think
                                      – HyperNeutrino
                                      Dec 19 '18 at 17:23




                                      @Shaggy fixed i think
                                      – HyperNeutrino
                                      Dec 19 '18 at 17:23




                                      1




                                      1




                                      @Shaggy Fixed it, thanks. Required a bit of a hack for cream since ca is a substring of cca for chocolate oof.
                                      – HyperNeutrino
                                      Dec 21 '18 at 15:48




                                      @Shaggy Fixed it, thanks. Required a bit of a hack for cream since ca is a substring of cca for chocolate oof.
                                      – HyperNeutrino
                                      Dec 21 '18 at 15:48











                                      1















                                      Charcoal, 69 68 63 56 bytes



                                      F⪪”E$↥l∧_∧K⁰RY⸿h⊕ψVG⌕gbW⟧⁼″5/²H✳<◨A³?ω↗⊘‴⭆1”²Φθ№κ⎇Σιlilι


                                      Try it online! Link is to verbose version of code. Explanation:



                                      F⪪”E$↥l∧_∧K⁰RY⸿h⊕ψVG⌕gbW⟧⁼″5/²H✳<◨A³?ω↗⊘‴⭆1”²


                                      Take the compressed string edyeeebrscckhrpeubivvifa99gohomaamrisiosazemuseypuwhpiorlu and loop over each substring of length 2.



                                      Φθ№κ⎇Σιlilι


                                      For each substring print those input strings that contain that substring, unless the substring is 99, in which case look for lil instead. (lilac is the only colour that does not have a unique two-letter substring; olive includes li; silver includes il and black includes lac. fawn and azure can be detected using just a single letter, but that doesn't help here.)






                                      share|improve this answer




























                                        1















                                        Charcoal, 69 68 63 56 bytes



                                        F⪪”E$↥l∧_∧K⁰RY⸿h⊕ψVG⌕gbW⟧⁼″5/²H✳<◨A³?ω↗⊘‴⭆1”²Φθ№κ⎇Σιlilι


                                        Try it online! Link is to verbose version of code. Explanation:



                                        F⪪”E$↥l∧_∧K⁰RY⸿h⊕ψVG⌕gbW⟧⁼″5/²H✳<◨A³?ω↗⊘‴⭆1”²


                                        Take the compressed string edyeeebrscckhrpeubivvifa99gohomaamrisiosazemuseypuwhpiorlu and loop over each substring of length 2.



                                        Φθ№κ⎇Σιlilι


                                        For each substring print those input strings that contain that substring, unless the substring is 99, in which case look for lil instead. (lilac is the only colour that does not have a unique two-letter substring; olive includes li; silver includes il and black includes lac. fawn and azure can be detected using just a single letter, but that doesn't help here.)






                                        share|improve this answer


























                                          1












                                          1








                                          1







                                          Charcoal, 69 68 63 56 bytes



                                          F⪪”E$↥l∧_∧K⁰RY⸿h⊕ψVG⌕gbW⟧⁼″5/²H✳<◨A³?ω↗⊘‴⭆1”²Φθ№κ⎇Σιlilι


                                          Try it online! Link is to verbose version of code. Explanation:



                                          F⪪”E$↥l∧_∧K⁰RY⸿h⊕ψVG⌕gbW⟧⁼″5/²H✳<◨A³?ω↗⊘‴⭆1”²


                                          Take the compressed string edyeeebrscckhrpeubivvifa99gohomaamrisiosazemuseypuwhpiorlu and loop over each substring of length 2.



                                          Φθ№κ⎇Σιlilι


                                          For each substring print those input strings that contain that substring, unless the substring is 99, in which case look for lil instead. (lilac is the only colour that does not have a unique two-letter substring; olive includes li; silver includes il and black includes lac. fawn and azure can be detected using just a single letter, but that doesn't help here.)






                                          share|improve this answer















                                          Charcoal, 69 68 63 56 bytes



                                          F⪪”E$↥l∧_∧K⁰RY⸿h⊕ψVG⌕gbW⟧⁼″5/²H✳<◨A³?ω↗⊘‴⭆1”²Φθ№κ⎇Σιlilι


                                          Try it online! Link is to verbose version of code. Explanation:



                                          F⪪”E$↥l∧_∧K⁰RY⸿h⊕ψVG⌕gbW⟧⁼″5/²H✳<◨A³?ω↗⊘‴⭆1”²


                                          Take the compressed string edyeeebrscckhrpeubivvifa99gohomaamrisiosazemuseypuwhpiorlu and loop over each substring of length 2.



                                          Φθ№κ⎇Σιlilι


                                          For each substring print those input strings that contain that substring, unless the substring is 99, in which case look for lil instead. (lilac is the only colour that does not have a unique two-letter substring; olive includes li; silver includes il and black includes lac. fawn and azure can be detected using just a single letter, but that doesn't help here.)







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited Dec 20 '18 at 9:59

























                                          answered Dec 19 '18 at 18:37









                                          Neil

                                          79.4k744177




                                          79.4k744177























                                              1














                                              Pyth, 66 bytes



                                              oxc."ayÇæ£ðÐ¥~@iF[2BÍÐ:Yë)^ksTTã"2s@LN,03


                                              Try it online here, or verify all the test cases at once here.



                                              The colours in the list can be uniquely identified by taking the characters at index 0 and 3, assuming modular indexing. This results in the following mapping:



                                              rr -> red
                                              yl -> yellow
                                              ge -> green
                                              bw -> brown
                                              sr -> scarlet
                                              bc -> black
                                              or -> ochre
                                              pc -> peach
                                              ry -> ruby
                                              ov -> olive
                                              vl -> violet
                                              fn -> fawn
                                              la -> lilac
                                              gd -> gold
                                              cc -> chocolate
                                              mv -> mauve
                                              ca -> cream
                                              cm -> crimson
                                              sv -> silver
                                              re -> rose
                                              ar -> azure
                                              lo -> lemon
                                              rs -> russet
                                              gy -> grey
                                              pp -> purple
                                              wt -> white
                                              pk -> pink
                                              on -> orange
                                              be -> blue


                                              Full explanation:



                                              oxc."..."2s@LN,03Q   Implicit: Q=eval(input())
                                              Trailing Q inferred, dictionary string replaced with ... for brevity
                                              o Q Order the elements of Q, as N, using:
                                              ,03 [0,3]
                                              @LN Get the characters at the above indices in N
                                              s Concatenate into a string
                                              The above is result {1}
                                              ."..." The compressed dictionary string
                                              c 2 Split into chunks of length 2
                                              x Get the index of {1} in the above
                                              Implicit print of sorted list





                                              share|improve this answer


























                                                1














                                                Pyth, 66 bytes



                                                oxc."ayÇæ£ðÐ¥~@iF[2BÍÐ:Yë)^ksTTã"2s@LN,03


                                                Try it online here, or verify all the test cases at once here.



                                                The colours in the list can be uniquely identified by taking the characters at index 0 and 3, assuming modular indexing. This results in the following mapping:



                                                rr -> red
                                                yl -> yellow
                                                ge -> green
                                                bw -> brown
                                                sr -> scarlet
                                                bc -> black
                                                or -> ochre
                                                pc -> peach
                                                ry -> ruby
                                                ov -> olive
                                                vl -> violet
                                                fn -> fawn
                                                la -> lilac
                                                gd -> gold
                                                cc -> chocolate
                                                mv -> mauve
                                                ca -> cream
                                                cm -> crimson
                                                sv -> silver
                                                re -> rose
                                                ar -> azure
                                                lo -> lemon
                                                rs -> russet
                                                gy -> grey
                                                pp -> purple
                                                wt -> white
                                                pk -> pink
                                                on -> orange
                                                be -> blue


                                                Full explanation:



                                                oxc."..."2s@LN,03Q   Implicit: Q=eval(input())
                                                Trailing Q inferred, dictionary string replaced with ... for brevity
                                                o Q Order the elements of Q, as N, using:
                                                ,03 [0,3]
                                                @LN Get the characters at the above indices in N
                                                s Concatenate into a string
                                                The above is result {1}
                                                ."..." The compressed dictionary string
                                                c 2 Split into chunks of length 2
                                                x Get the index of {1} in the above
                                                Implicit print of sorted list





                                                share|improve this answer
























                                                  1












                                                  1








                                                  1






                                                  Pyth, 66 bytes



                                                  oxc."ayÇæ£ðÐ¥~@iF[2BÍÐ:Yë)^ksTTã"2s@LN,03


                                                  Try it online here, or verify all the test cases at once here.



                                                  The colours in the list can be uniquely identified by taking the characters at index 0 and 3, assuming modular indexing. This results in the following mapping:



                                                  rr -> red
                                                  yl -> yellow
                                                  ge -> green
                                                  bw -> brown
                                                  sr -> scarlet
                                                  bc -> black
                                                  or -> ochre
                                                  pc -> peach
                                                  ry -> ruby
                                                  ov -> olive
                                                  vl -> violet
                                                  fn -> fawn
                                                  la -> lilac
                                                  gd -> gold
                                                  cc -> chocolate
                                                  mv -> mauve
                                                  ca -> cream
                                                  cm -> crimson
                                                  sv -> silver
                                                  re -> rose
                                                  ar -> azure
                                                  lo -> lemon
                                                  rs -> russet
                                                  gy -> grey
                                                  pp -> purple
                                                  wt -> white
                                                  pk -> pink
                                                  on -> orange
                                                  be -> blue


                                                  Full explanation:



                                                  oxc."..."2s@LN,03Q   Implicit: Q=eval(input())
                                                  Trailing Q inferred, dictionary string replaced with ... for brevity
                                                  o Q Order the elements of Q, as N, using:
                                                  ,03 [0,3]
                                                  @LN Get the characters at the above indices in N
                                                  s Concatenate into a string
                                                  The above is result {1}
                                                  ."..." The compressed dictionary string
                                                  c 2 Split into chunks of length 2
                                                  x Get the index of {1} in the above
                                                  Implicit print of sorted list





                                                  share|improve this answer












                                                  Pyth, 66 bytes



                                                  oxc."ayÇæ£ðÐ¥~@iF[2BÍÐ:Yë)^ksTTã"2s@LN,03


                                                  Try it online here, or verify all the test cases at once here.



                                                  The colours in the list can be uniquely identified by taking the characters at index 0 and 3, assuming modular indexing. This results in the following mapping:



                                                  rr -> red
                                                  yl -> yellow
                                                  ge -> green
                                                  bw -> brown
                                                  sr -> scarlet
                                                  bc -> black
                                                  or -> ochre
                                                  pc -> peach
                                                  ry -> ruby
                                                  ov -> olive
                                                  vl -> violet
                                                  fn -> fawn
                                                  la -> lilac
                                                  gd -> gold
                                                  cc -> chocolate
                                                  mv -> mauve
                                                  ca -> cream
                                                  cm -> crimson
                                                  sv -> silver
                                                  re -> rose
                                                  ar -> azure
                                                  lo -> lemon
                                                  rs -> russet
                                                  gy -> grey
                                                  pp -> purple
                                                  wt -> white
                                                  pk -> pink
                                                  on -> orange
                                                  be -> blue


                                                  Full explanation:



                                                  oxc."..."2s@LN,03Q   Implicit: Q=eval(input())
                                                  Trailing Q inferred, dictionary string replaced with ... for brevity
                                                  o Q Order the elements of Q, as N, using:
                                                  ,03 [0,3]
                                                  @LN Get the characters at the above indices in N
                                                  s Concatenate into a string
                                                  The above is result {1}
                                                  ."..." The compressed dictionary string
                                                  c 2 Split into chunks of length 2
                                                  x Get the index of {1} in the above
                                                  Implicit print of sorted list






                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered Dec 20 '18 at 10:46









                                                  Sok

                                                  3,537722




                                                  3,537722























                                                      1















                                                      05AB1E, 48 bytes



                                                      Σ.•Aå₂мÕh∊þèmvƶkΛ1YŠíJ>J#θ₁2©€,Ù{η¦ù-•2ôy¬s3è«k


                                                      Same solution as most other answers. Will try to golf it down from here later.



                                                      Try it online or verify all test cases.



                                                      Explanation:





                                                      Σ          # Sort the (implicit) input-list by:
                                                      .•Aå₂мÕh∊þèmvƶkΛ1YŠíJ>J#θ₁2©€,Ù{η¦ù-•
                                                      # Push compressed string "rrylgebwsrbcorpcryovvlfnlagdccmvcacmsvrearlorsgyppwtpkonbe"
                                                      2ô # Split into parts of size 2
                                                      y # Push the current string of the list we're sorting
                                                      ¬ # Push its head (without popping)
                                                      s # Swap so the string is at the top of the stack again
                                                      3è # Get the character at index 3 (with automatic wraparound)
                                                      « # Merge both characters together
                                                      k # And get the index in the compressed string to sort on


                                                      See this 05AB1E tip (section How to compress strings not part of the dictionary?) to understand how .•Aå₂мÕh∊þèmvƶkΛ1YŠíJ>J#θ₁2©€,Ù{η¦ù-• is "rrylgebwsrbcorpcryovvlfnlagdccmvcacmsvrearlorsgyppwtpkonbe".






                                                      share|improve this answer


























                                                        1















                                                        05AB1E, 48 bytes



                                                        Σ.•Aå₂мÕh∊þèmvƶkΛ1YŠíJ>J#θ₁2©€,Ù{η¦ù-•2ôy¬s3è«k


                                                        Same solution as most other answers. Will try to golf it down from here later.



                                                        Try it online or verify all test cases.



                                                        Explanation:





                                                        Σ          # Sort the (implicit) input-list by:
                                                        .•Aå₂мÕh∊þèmvƶkΛ1YŠíJ>J#θ₁2©€,Ù{η¦ù-•
                                                        # Push compressed string "rrylgebwsrbcorpcryovvlfnlagdccmvcacmsvrearlorsgyppwtpkonbe"
                                                        2ô # Split into parts of size 2
                                                        y # Push the current string of the list we're sorting
                                                        ¬ # Push its head (without popping)
                                                        s # Swap so the string is at the top of the stack again
                                                        3è # Get the character at index 3 (with automatic wraparound)
                                                        « # Merge both characters together
                                                        k # And get the index in the compressed string to sort on


                                                        See this 05AB1E tip (section How to compress strings not part of the dictionary?) to understand how .•Aå₂мÕh∊þèmvƶkΛ1YŠíJ>J#θ₁2©€,Ù{η¦ù-• is "rrylgebwsrbcorpcryovvlfnlagdccmvcacmsvrearlorsgyppwtpkonbe".






                                                        share|improve this answer
























                                                          1












                                                          1








                                                          1







                                                          05AB1E, 48 bytes



                                                          Σ.•Aå₂мÕh∊þèmvƶkΛ1YŠíJ>J#θ₁2©€,Ù{η¦ù-•2ôy¬s3è«k


                                                          Same solution as most other answers. Will try to golf it down from here later.



                                                          Try it online or verify all test cases.



                                                          Explanation:





                                                          Σ          # Sort the (implicit) input-list by:
                                                          .•Aå₂мÕh∊þèmvƶkΛ1YŠíJ>J#θ₁2©€,Ù{η¦ù-•
                                                          # Push compressed string "rrylgebwsrbcorpcryovvlfnlagdccmvcacmsvrearlorsgyppwtpkonbe"
                                                          2ô # Split into parts of size 2
                                                          y # Push the current string of the list we're sorting
                                                          ¬ # Push its head (without popping)
                                                          s # Swap so the string is at the top of the stack again
                                                          3è # Get the character at index 3 (with automatic wraparound)
                                                          « # Merge both characters together
                                                          k # And get the index in the compressed string to sort on


                                                          See this 05AB1E tip (section How to compress strings not part of the dictionary?) to understand how .•Aå₂мÕh∊þèmvƶkΛ1YŠíJ>J#θ₁2©€,Ù{η¦ù-• is "rrylgebwsrbcorpcryovvlfnlagdccmvcacmsvrearlorsgyppwtpkonbe".






                                                          share|improve this answer













                                                          05AB1E, 48 bytes



                                                          Σ.•Aå₂мÕh∊þèmvƶkΛ1YŠíJ>J#θ₁2©€,Ù{η¦ù-•2ôy¬s3è«k


                                                          Same solution as most other answers. Will try to golf it down from here later.



                                                          Try it online or verify all test cases.



                                                          Explanation:





                                                          Σ          # Sort the (implicit) input-list by:
                                                          .•Aå₂мÕh∊þèmvƶkΛ1YŠíJ>J#θ₁2©€,Ù{η¦ù-•
                                                          # Push compressed string "rrylgebwsrbcorpcryovvlfnlagdccmvcacmsvrearlorsgyppwtpkonbe"
                                                          2ô # Split into parts of size 2
                                                          y # Push the current string of the list we're sorting
                                                          ¬ # Push its head (without popping)
                                                          s # Swap so the string is at the top of the stack again
                                                          3è # Get the character at index 3 (with automatic wraparound)
                                                          « # Merge both characters together
                                                          k # And get the index in the compressed string to sort on


                                                          See this 05AB1E tip (section How to compress strings not part of the dictionary?) to understand how .•Aå₂мÕh∊þèmvƶkΛ1YŠíJ>J#θ₁2©€,Ù{η¦ù-• is "rrylgebwsrbcorpcryovvlfnlagdccmvcacmsvrearlorsgyppwtpkonbe".







                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered Dec 21 '18 at 8:52









                                                          Kevin Cruijssen

                                                          35.6k554186




                                                          35.6k554186






























                                                              draft saved

                                                              draft discarded




















































                                                              If this is an answer to a challenge…




                                                              • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                              • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                Explanations of your answer make it more interesting to read and are very much encouraged.


                                                              • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                                              More generally…




                                                              • …Please make sure to answer the question and provide sufficient detail.


                                                              • …Avoid asking for help, clarification or responding to other answers (use comments instead).






                                                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                              Please pay close attention to the following guidance:


                                                              • Please be sure to answer the question. Provide details and share your research!

                                                              But avoid



                                                              • Asking for help, clarification, or responding to other answers.

                                                              • Making statements based on opinion; back them up with references or personal experience.


                                                              To learn more, see our tips on writing great answers.




                                                              draft saved


                                                              draft discarded














                                                              StackExchange.ready(
                                                              function () {
                                                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f177786%2fcoat-of-many-colours%23new-answer', 'question_page');
                                                              }
                                                              );

                                                              Post as a guest















                                                              Required, but never shown





















































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown

































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown







                                                              Popular posts from this blog

                                                              Morgemoulin

                                                              Scott Moir

                                                              Souastre