This basically sorts color codes.
perl -e'print sort { hex(substr($a,1,6)) <=> hex(substr($b,1,6)) } ("#FF0000","#00FF00","#0000FF","#FF00FF","#FFFF00")'

Replies are listed 'Best First'.
(bbfu) Re: Sorting Color codes
by bbfu (Curate) on Sep 14, 2001 at 06:22 UTC

    Hrm. Maybe I'm missing something, but what's wrong with a simple sort?

    perl -e 'print sort qw(#FF0000 #00FF00 #0000FF #FF00FF #FFFF00)'

    It returns the same sorted-order as your code (namely: #0000FF, #00FF00, #FF0000, #FF00FF, #FFFF00) and it's simpler.

    bbfu
    Seasons don't fear The Reaper.
    Nor do the wind, the sun, and the rain.
    We can be like they are.