in reply to Date to be sorted in descending and time in ascending
You just need a custom sort method. Break the string into the date part and time part, and give the proper comparisons. Something like this:
my @sorted = sort { substr($b,0,8) <=> substr($a,0,8) || substr($a,8) +<=> substr($b,8) } @unsorted;
The first chunk breaks the date part off of the string, and sorts it in reverse order (note $b is on the left, $a on the right). In the case when the dates are the same, it breaks the time off the string and sorts it in ascending order ($a on the left, $b on the right).
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Date to be sorted in descending and time in ascending
by aaron_baugher (Curate) on May 18, 2012 at 21:22 UTC | |
by roboticus (Chancellor) on May 19, 2012 at 12:14 UTC | |
by aaron_baugher (Curate) on May 19, 2012 at 18:11 UTC |