Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Sorting dates with the Schwartzian Transform

by ikegami (Pope)
on Aug 03, 2011 at 18:21 UTC ( #918353=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @sorted =
       map substr($_, 8),
       sort
       map join('', (/(..)-(..)-(....)/)[2,1,0], $_),
       @dates;  # DD-MM-YYYY
    
  2. or download this
    my @sorted =
       sort {
    ...
          join('', ($b =~ /(..)-(..)-(....)/)[2,1,0])
       }
       @dates;  # DD-MM-YYYY
    
  3. or download this
    my @sorted =
       map $_->[0],
       sort { $a->[1] cmp $b->[1] }
       map [ $_, join('', (/(..)-(..)-(....)/)[2,1,0]) ],
       @dates;  # DD-MM-YYYY
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2014-11-26 18:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (172 votes), past polls