Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Sorting by Date Help!

by poolpi (Hermit)
on Mar 17, 2009 at 22:11 UTC ( [id://751293]=note: print w/replies, xml ) Need Help??


in reply to Sorting by Date Help!

use strict; use warnings; use DateTime; my @sorted_dates = sort { DateTime->compare_ignore_floating($$b{'submitted'}, $$a{'submitted'}) } map { my ( $month, $day, $year ) = ( split( '/', $_ ) )[ 0 .. 2 ]; { qq(submitted), DateTime->new( year => $year + 2000, month => $month, day => $day, time_zone => 'Europe/Paris', ) } } qw{ 01/22/08 01/12/08 04/01/09 10/04/08 01/10/09 12/12/09 01/22/0 +9 01/12/09 12/30/08 12/22/08 12/15/08 01/05/09 01/19/09 01/21/09}; print $sorted_dates[$_]{'submitted'}->mdy('/'), "\n" for 0 .. $#sorted_dates; __END__ Output: 12/12/2009 04/01/2009 01/22/2009 01/21/2009 01/19/2009 01/12/2009 01/10/2009 01/05/2009 12/30/2008 12/22/2008 12/15/2008 10/04/2008 01/22/2008 01/12/2008


hth,
PooLpi

'Ebry haffa hoe hab im tik a bush'. Jamaican proverb

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-20 04:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found