in reply to Sorting a Hash Ref
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sorting a Hash Ref
by friedo (Prior) on Oct 26, 2005 at 20:31 UTC | |
by Juerd (Abbot) on Oct 26, 2005 at 20:34 UTC | |
|
Re^2: Sorting a Hash Ref
by bkiahg (Pilgrim) on Oct 26, 2005 at 17:25 UTC | |
by sauoq (Abbot) on Oct 26, 2005 at 18:23 UTC | |
by bkiahg (Pilgrim) on Oct 26, 2005 at 20:28 UTC | |
by kwaping (Priest) on Oct 26, 2005 at 18:21 UTC | |
by bkiahg (Pilgrim) on Oct 26, 2005 at 19:09 UTC |