in reply to Sorting Array of dates in PERL
The DateTime module overloads the string/numeric comparison operators ('<=>' and 'cmp'), so if you can get them into DateTime objects instead of strings, you can use a trivial sort operation (my @sorted_dates = sort { $a <=> $b } @unsorted_dates;.
Otherwise, if you store them in DDMMYYYY format, you can do the same thing (or use 'cmp' if you have slashes in the date). Personally, I prefer to use DateTime since I don't want to be constrained by a specific format.
----
send money to your kernel via the boot loader.. This and more wisdom available from Markov Hardburn.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sorting Array of dates in PERL
by meetraz (Hermit) on Jun 28, 2004 at 21:15 UTC | |
by hardburn (Abbot) on Jun 28, 2004 at 21:17 UTC |