I want to sort a hash of  hash by date&time and then extract some of
the data.

>From the data ive got i can contruct a key that is yyyymmddhhmm

and i do this
##error trap absent entries
if ($endan=~m/\d{2}:\d{2}\s+\d{2}/ && $stan=~m/\d{2}:\d{2}\s+\d{2}/ )
          {my %daylist;
##split start and end date and time
my ($endhour,$endmin,$endday,$endmonth,$endyear)=split(/[\ |:|\/]/,
$endan);
my($sthour,$stmin,$stday,$stmonth,$styear)=split(/[\ |:|\/]/,$stan);

##if its at weekends ( for instance )
my $day = (Date_DayOfWeek($stmonth,$stday,$styear)*1);
if ($day>5 )
         {
my $fd="$styear$stmonth$stday$sthour$stmin";
$daylist{$fd}=\%$br;
       }
foreach $key (sort (keys(%daylist)))
                  {
print "$key ";print $daylist{$key};print "\n";
                }
print "---\n";
     }

gives me output like this
for 1 Oct
---
200610011733 HASH(0x8510560)
---
200610012057 HASH(0x85b3434)
---
200610011029 HASH(0x85732a0)
---
200610010928 HASH(0x86268a4)
---
200610011220 HASH(0x86270fc)

so th print out is in the order
17:33
20:57
10:29
09:28
12:20

and my data for the 7th oct 2006
---
200610071321 HASH(0x859cfdc)
---
200610071156 HASH(0x85a17e8)
---
200610071514 HASH(0x85a2034)
---
which is

13:21 HASH(0x859cfdc)
11:56 HASH(0x85a17e8)
15:14 HASH(0x85a2034)

so its not sorted as I want


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to