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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.