Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Sorting dates with the Schwartzian Transform

by FunkyMonk (Canon)
on Aug 03, 2011 at 16:20 UTC ( #918321=note: print w/ replies, xml ) Need Help??

in reply to Sorting dates with the Schwartzian Transform

Do I have to convert this column before the ST to a number,
A number or a string, it makes little difference
and after the ST convert it back to the DD-MM-YYYY format?
No, you just throw the sortable number/string away. Something like this:
print for map { $_->[0] } # extract original date sort { $a->[1] cmp $b->[1] } # Sort, using sortable date map { m/(\d\d)-(\d\d)-(\d{4})/; [$_, "$3$2$1"] # [original date, sortable date +] } <DATA>; __DATA__ 02-02-2007 01-01-2006 03-03-2009 02-02-2009


01-01-2006 02-02-2007 02-02-2009 03-03-2009

Unless I state otherwise, all my code runs with strict and warnings

Comment on Re: Sorting dates with the Schwartzian Transform
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2015-12-02 03:32 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (32 votes), past polls