in reply to Re^3: Sorting by Date Help!
in thread Sorting by Date Help!

I tried like that and did not get the dates in the order of the most recent dates on top.
my @data; push @data, {date => '01-03-08'}; push @data, {date => '04-04-09'}; push @data, {date => '12-01-08'}; push @data, {date => '12-01-09'}; push @data, {date => '08-10-08'}; my @sorted = sort { $a->{date} <=> $b->{date} } @data; foreach my $res(@sorted) { print $res->{ date }."\n\n"; }

Replies are listed 'Best First'.
Re^5: Sorting by Date Help!
by moritz (Cardinal) on Mar 17, 2009 at 19:11 UTC
    You need to put the year first in the date (not last; use the format YY-MM-DD, and then use cmp for comparison, not <=>. Then all that's left is reversing the order, which you'll surely figure out yourself.