Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: sorting mm/dd/yy

by Hot Pastrami (Monk)
on Dec 15, 2000 at 04:26 UTC ( #46766=note: print w/replies, xml ) Need Help??


in reply to sorting mm/dd/yy

If you're stuck with that lousy date format, something like this could work for your sorting sub:
sub sortDates { my ($month1, $day1, $year1) = split /\//, $a; my ($month2, $day2, $year2) = split /\//, $b; $year1 += 1900 if $year1 < 50; $year2 += 1900 if $year2 < 50; $year1 <=> $year2 or $month1 <=> $month2 or $day1 <=> $day2; }
...however this assumes that none of the dates are older than 1950... you may need to adjust the '50' to fit your values.

Alan "Hot Pastrami" Bellows

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://46766]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2021-01-17 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?