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
Output:
01-01-2006 02-02-2007 02-02-2009 03-03-2009
|
---|
In Section
Seekers of Perl Wisdom