shift9999 has asked for the wisdom of the Perl Monks concerning the following question:
I have been reviewing the perlfaq on using the sort function correctly but so far have not been able to get the exact output I need.
I have a hash setup with the dates and times as the keys and the data as the value. I need to sort the dates and times properly. this would normally not be a big issue but the times are in 12 hour format.
here is the format of the hash:Here is the sort:$line_data{"9/10 @ 12:45 PM"} = "some superfluous data here";
This will sort the dates and times but seems to ignore the AM/PM.foreach $key (sort (keys(%line_data))) { print "$key $line_data{$key}\n"; }
The code above does not reflect it but I have tried expanding on the sort with a custom sub called from it. I have not been sucessfull in setting up the right comparison code. More information to follow as I tinker with the sort helper sub.
Any help would be appreciated.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Hash sorting with dates and 12 hour time format.
by Roy Johnson (Monsignor) on Sep 15, 2009 at 21:15 UTC | |
Re: Hash sorting with dates and 12 hour time format.
by gwadej (Chaplain) on Sep 15, 2009 at 21:09 UTC | |
Re: Hash sorting with dates and 12 hour time format.
by ikegami (Patriarch) on Sep 15, 2009 at 21:30 UTC | |
Re: Hash sorting with dates and 12 hour time format.
by ramlight (Friar) on Sep 15, 2009 at 21:14 UTC | |
by shift9999 (Acolyte) on Sep 15, 2009 at 21:33 UTC |