in reply to Date to be sorted in descending and time in ascending
Sort::Key is pretty awesome for this kind of thing.
use 5.010; use strict; use Sort::Key qw(multikeysorter); my $sorter = multikeysorter( sub { /^(.{8})(.{6})/ }, # how to split into keys qw( -int int ), # how to sort each key ); my @dateArray = grep { 1+chomp } <DATA>; say for $sorter->(@dateArray); __DATA__ 20010405000000 20050405005000 20020405081200 20080405022500 20080405022600 20080405023500 20090405022500 20090405022300 20090405022900 20090405022100
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Date to be sorted in descending and time in ascending
by salva (Canon) on May 18, 2012 at 17:28 UTC |