Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Date to be sorted in descending and time in ascending

by johngg (Abbot)
on May 18, 2012 at 21:04 UTC ( #971368=note: print w/ replies, xml ) Need Help??


in reply to Date to be sorted in descending and time in ascending

A GRT just for some variety.

knoppix@Microknoppix:~$ perl -E ' > my @dates = qw{ > 20010405000000 > 20050405005000 > 20020405081200 > 20080405022500 > 20080405022600 > 20080405023500 > 20090405022500 > 20090405022300 > 20090405022900 > 20090405022100 > }; > > say for > map { substr $_, 8 } > sort > map { pack q{NNA*}, 0 - substr( $_, 0, 8 ), 0 + substr( $_, 8 ), + $_ } > @dates;' 20090405022100 20090405022300 20090405022500 20090405022900 20080405022500 20080405022600 20080405023500 20050405005000 20020405081200 20010405000000 knoppix@Microknoppix:~$

Cheers,

JohnGG


Comment on Re: Date to be sorted in descending and time in ascending
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (16)
As of 2014-11-25 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (158 votes), past polls