Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

(Date::Manip) Re: sorting mm/dd/yy

by mwp (Hermit)
on Dec 15, 2000 at 04:10 UTC ( #46761=note: print w/replies, xml ) Need Help??


in reply to sorting mm/dd/yy

A quick search of the Date::Manip perldoc yields this:
use Date::Manip qw(ParseDate Date_Cmp); sub sortDate { my($date1, $date2); $date1 = &ParseDate($a); $date2 = &ParseDate($b); return (&Date_Cmp($date1,$date2)); } my @dates = ("Fri 16 Aug 96", "Mon 19 Aug 96", "Thu 15 Aug 96"); my @i = sort &sortDate @dates;
(edited somewhat for clarity)

You could also write this as:

my @i = sort { &Date_Cmp(&ParseDate($a),&ParseDate($b)) } @dates;

Replies are listed 'Best First'.
Re: (Date::Manip) Re: sorting mm/dd/yy
by merlyn (Sage) on Dec 15, 2000 at 04:13 UTC

Log In?
Username:
Password:

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

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