[Removed beginners-cgi list; this ha nothing to do with CGIs.]

At 04:24 PM 8/6/01 +0930, Daniel Falkenberg wrote:
>Does any one know the best way of sortig by YEAR MONTH DAY?
>
>I would like my script to dispalay 20010327 which is YEAR 2001 MONTH 10 and
>DAY 27

A little experimentation should convince you that if you turn a date of 
MM/DD/YYYY into the number YYYYMMDD then those dates will sort 
numerically.  All you have to do is make sure the month and day are zero 
filled to two spaces, so:

         $date = sprintf "%s%02d%02d", $year, $month, $day;

and you can then just sort an array of those with

         sort { $a <=> $b } @dates;

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to