wube has asked for the wisdom of the Perl Monks concerning the following question:
1. What do I need to do to make the sort on weekday order by day of week ??#!/usr/local/bin/perl -w @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" ) ; $count=@data ; print "debug-->data has $count lines \n" ; foreach $line (@data) { chomp $line ; print "$line \n" ; } # Sort on Weekday, time and policy @out1 = sort { @a = (split ',', $a) ; @b = (split ',', $b) ; $a[7] cmp $b[7] || $a[8] cmp $b[8] || $a[0] cmp $b[0] } @data ; $count=@out1 ; print "debug-->out1 has $count lines \n" ; foreach $line (@out1) { chomp $line ; print "$line \n" ; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sort questions
by Tanktalus (Canon) on Jan 28, 2005 at 21:46 UTC | |
by wube (Acolyte) on Feb 01, 2005 at 14:42 UTC | |
|
Re: Sort questions
by Limbic~Region (Chancellor) on Jan 28, 2005 at 21:39 UTC | |
by wube (Acolyte) on Jan 31, 2005 at 17:03 UTC | |
by Limbic~Region (Chancellor) on Jan 31, 2005 at 17:38 UTC | |
by wube (Acolyte) on Feb 01, 2005 at 14:24 UTC | |
|
Re: Sort questions (use a GRT)
by grinder (Bishop) on Jan 28, 2005 at 22:03 UTC | |
|
Re: Sort questions
by johnnywang (Priest) on Jan 28, 2005 at 21:48 UTC | |
by wube (Acolyte) on Feb 01, 2005 at 14:50 UTC | |
|
Re: Sort questions
by wube (Acolyte) on Jan 29, 2005 at 16:29 UTC |