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]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2016-10-24 16:32 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (309 votes). Check out past polls.