in reply to sort based on date
If you are looking for speed, I'd recommend something like this (trading space for time + process your string using native functions):
my %h1 = ( 'Jan' => 'a', 'Feb' => 'b', ... 'Dec' => 'l', ); my %h2 = ( 'a' => 'Jan', 'b' => 'Feb', ... 'l' => 'Dec', ); my @sorted_dates = grep { s/^(.)(\d\d)/$e{$1} . ' ' . sprintf("%d",$2)/e } sort grep { s/^(.{3}) (\d\d?)/$d{$1} . sprintf("%02d",$2)/e; } @dates;
Of course you can/must rework the regex'es according to string format. Compared to code using Date::Manip, this one runs ~200 times faster (on my system)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sort based on date
by Anonymous Monk on Aug 08, 2010 at 20:12 UTC | |
by ikegami (Patriarch) on Aug 08, 2010 at 21:36 UTC | |
by Anonymous Monk on Aug 09, 2010 at 11:15 UTC |