Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^3: sorting dates in YYYYMMDD format

by 2teez (Priest)
on Jul 04, 2013 at 08:17 UTC ( #1042377=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
    use re 'debug';
       map [ $_, join('', (/(..)(..)(....)/)[0,1,2]) ],
       @dates;  # DD-MM-YYYY
    print "@sorted\n";
  2. or download this
    Compiling REx `(..)(..)(....)'
    size 21 Got 172 bytes for offset annotations.
    Match successful!
    20130401 20130501 20130601
    Freeing REx: `"(..)(..)(....)"'
  3. or download this
    use warnings;
    use strict;
    print join ' ' => map{$_->[0]}
                  sort{$a->[1] <=> $b->[1]}
                  map{/.{4}(.{2})/;[$_,$1]} @dates;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1042377]
[marto]: good morning all
[prospect]: Good morning ! More Perl learning today, Man that subroutines chapter is tough.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2017-07-24 07:53 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (348 votes). Check out past polls.