You can use the Schwarzian Transform, something like:
use strict; my @data = ( "aix-dev,active,aixr03,aixr03,crmd,FULL,12345,Sunday,018:00:00", "w2k-prod,active,w2k-PROD,pub1hi,prod-web-srv1Y,FULL,3,Friday, +021:00:00", "w2k-prod,active,w2k-PROD,pol02pi,prod-web-srv1,CINC,,Monday,0 +09:00:00", "w2k-prod,active,w2k-PROD,pub01pi,prod-web-srv1,CINC,,Monday,0 +23:00:000", "aix-dev-ecmd2,active,aixr03,aixr03,ecmD2,FULL,12345,Monday,00 +1:00:00", "aix-prod-artp,active,aixr04,aixr04,artp-rman,FULL,2345,Sunday +,021:30:00", "w2k-prod,active,w2k-PROD,pol02pi,prod-web-srv1Y,FULL,3,Friday +,023:00:00", "w2k-prod,active,w2k-PROD,pub01pi,prod-web-srv1Y,FULL,3,Friday +,021:00:00" ) ; my %hash = (Sunday=>0,Monday=>1,Tuesday=>2,Wednesday=>3, Thursday=>4,Friday=>5,Saturday=>6); print map { $_->[0] } sort { $a->[1] <=> $b->[1] #week || $a->[2] <=> $b->[2] #hour || $a->[3] <=> $b->[3] # minute || $a->[4] <=> $b->[4] # second || $a->[5] cmp $b->[5] #policy } map { [ $_, compute($_)] } @data; sub compute{ my @items = split(/,/,shift); my @time = split(/:/,$items[8]); return ($hash{$items[7]},@time,$items[0]); } __END__ # output: aix-dev,active,aixr03,aixr03,crmd,FULL,12345,Sunday,018:00:00 aix-prod-artp,active,aixr04,aixr04,artp-rman,FULL,2345,Sunday,021:30:0 +0 aix-dev-ecmd2,active,aixr03,aixr03,ecmD2,FULL,12345,Monday,001:00:00 w2k-prod,active,w2k-PROD,pol02pi,prod-web-srv1,CINC,,Monday,009:00:00 w2k-prod,active,w2k-PROD,pub01pi,prod-web-srv1,CINC,,Monday,023:00:000 w2k-prod,active,w2k-PROD,pub1hi,prod-web-srv1Y,FULL,3,Friday,021:00:00 w2k-prod,active,w2k-PROD,pub01pi,prod-web-srv1Y,FULL,3,Friday,021:00:0 +0 w2k-prod,active,w2k-PROD,pol02pi,prod-web-srv1Y,FULL,3,Friday,023:00:0 +0

In reply to Re: Sort questions by johnnywang
in thread Sort questions by wube

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.