This assumes the month and day fields are both always 2-characters wide. If they are not, then visit CPAN,/a> and find a Date module to do the comparision.my %sorted = sort { $a->{old_file} cmp $b->{old_file} } (keys %{$hashref}); my $sorted = \%sorted; # or put { } around the sort expression to do it one line.
For example Date::Manip has a Date_Cmp function, whose docs say:
This takes two dates and compares them. Almost all dates can be compared using the perl "cmp" command. The only time this will not work is when comparing dates in different timezones. This routine will take that into account.
In reply to Re: Sorting a Hash Ref
by metaperl
in thread Sorting a Hash Ref
by bkiahg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |