Based on Math behind Colourspace Conversions, I was able to at least sort the colours:
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; sub hue { my ($colour) = @_; my %rgb; @rgb{qw{ red green blue }} = map hex($_) / 255, $colour =~ /^#(..) +(..)(..)/; my @order = sort { $rgb{$a} <=> $rgb{$b} } keys %rgb; my $hue = {red => sub { 0 + $rgb{green} - $rgb{blue}}, green => sub { 2 + $rgb{blue} - $rgb{red} }, blue => sub { 4 + $rgb{red} - $rgb{green} } }->{ $order[2] }->(); my $d = $rgb{ $order[2] } - $rgb{ $order[0]}; return 0 if 0 == $d; $hue /= $d; $hue *= 60; $hue += 360 if $hue < 0; return $hue } my @colours = do { no warnings 'qw'; qw( #000000 #716373 #704A2B #AF7E45 #963049 #AA2261 #B24551 #E6212E #FF0000 #001200 #FFDE72 #F55B73 + ) }; my %hue = map { $_ => hue($_) } @colours; my @sorted = sort { $hue{$a} <=> $hue{$b} } keys %hue; say "@sorted";
The black/white problem is not solved here, so feel free to expand as you need.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

In reply to Re: Ordering Colours Problem by choroba
in thread Ordering Colours Problem by merrymonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.