Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need 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

In reply to Re: Sorting by Date Help! by poolpi
in thread Sorting by Date Help! by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-23 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found