in reply to Sorting by date
and the output:use strict; use Data::Dumper; my @date = qw/ 1.13.04 1.12.04 3.13.04 /; my @sorted_date = map { $_->[0] } # retrieve the original date sort { $b->[1] <=> $a->[1] } # sort the normalized date map { my @n = /(\d+)\.(\d+)\.(\d+)/; # normalize the date my $d = sprintf "%02d%02d%02d", @n[2,0,1]; [$_, $d] } @date; print Dumper(\@sorted_date);
$VAR1 = [ '3.13.04', '1.13.04', '1.12.04' ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Sorting by date
by Anonymous Monk on Jan 06, 2004 at 01:12 UTC | |
by Roger (Parson) on Jan 06, 2004 at 01:19 UTC | |
by Anonymous Monk on Jan 06, 2004 at 01:53 UTC | |
by Roger (Parson) on Jan 06, 2004 at 02:00 UTC | |
by sulfericacid (Deacon) on Jan 06, 2004 at 10:40 UTC | |
by Roger (Parson) on Jan 06, 2004 at 12:39 UTC | |
by Anonymous Monk on Jan 07, 2004 at 05:48 UTC | |
by Roger (Parson) on Jan 07, 2004 at 06:26 UTC |