madtoperl has asked for the wisdom of the Perl Monks concerning the following question:
Could any of you please help me to display the hash data sorted by date?$dateOut = "$oDay".'-'."$oMon".'-'."$oYear"; #print"Date out => $dateOut\n"; $Date_Time{$dateOut}{$dSec}{$dMin}{$dHour} = 1 +; #Retrieving the hash array output foreach my $date ( sort keys %Date_Time ) { #print"Date=> $date\n"; foreach my $sec (sort keys %{$Date_Time{$date}}) { #print"Seconds=> $sec\n"; foreach my $minute (sort keys %{$Date_Time{$date}{$sec}}) +{ #print"Minute=> $minute\n"; foreach my $ hour (sort keys %{$Date_Time{$date}{$sec} +{$minute}}) { print"Date=>[$date] --> [$hour]:[$minute]:[$sec]\n +"; } } } } My Output: Date=>04-12-2008 --> 8:5:0 Date=>03-12-2008 --> 5:8:0 Date=>05-12-2008 --> 9:5:0 Expected output: Date=>03-12-2008 --> 5:8:0 Date=>04-12-2008 --> 8:5:0 Date=>05-12-2008 --> 9:5:0
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sort Hash array using date
by Corion (Patriarch) on Jan 15, 2009 at 16:46 UTC | |
|
Re: Sort Hash array using date
by linuxer (Curate) on Jan 15, 2009 at 16:56 UTC | |
|
Re: Sort Hash array using date
by gone2015 (Deacon) on Jan 15, 2009 at 17:40 UTC | |
|
Re: Sort Hash array using date
by jethro (Monsignor) on Jan 15, 2009 at 17:14 UTC | |
|
Re: Sort Hash array using date
by setebos (Beadle) on Jan 15, 2009 at 16:57 UTC |