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

Still did not work

In what way? I'm surprised... show us what code you've tried, so that we can tell you what's wrong and how to fix it.

push @data, {name => "Submitted", date => 01/03/08 };

If you write 01/03/08 it will complain with Illegal octal digit '8' at.

Would that sort by the most recent date?

No, because you still haven't fixed the comparison semantics.

Replies are listed 'Best First'.
Re^4: Sorting by Date Help!
by Anonymous Monk on Mar 17, 2009 at 19:08 UTC
    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"; }

      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.