I'm in a good mood, so I'll give you (untested) code:
my @sorted_dates = map { $_->{'date'} }
sort { $a->{'year'} <=> $b->{'year} or
$a->{'month'} <=> $b->{'month} or
$a->{'day'} <=> $b->{'day'} }
map { /(\d\d)-(\d\d)-(\d\d\d\d)/ ;
{ 'date' => $_,
'day' => $1,
'month' => $2,
'year' => $3 } } @start_date;
my $minimum_date = $sorted_dates[-1];
Basically, I'm using a Schwartzian Transform in which I'm retrieving the elements of the date (year, month and day) and I'm sorting the dates by using those elements.
Search for "Schwartzian Transform" here in the Monastery if you don't know what it is. As for the rest, it's just a matter of sorting by year, by month if the years are the same, and by day if the months are the same.
Note that I'm assuming two digit days and two digit months. |