Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 about the Monastery: (10)
As of 2016-06-29 18:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (385 votes). Check out past polls.