in reply to sorting dates in YYYYMMDD format
On of the great things about YYYYMMDD is that if you sort it numerically you get it properly sorted. So just do
@ordered = sort { $a <=> $b } @dates;
Comment: your expected output is as wrong as your output you get, they are identical... And in your code, $d is never defined. And the example is badly chosen as all parts are identical apart from the month. In this case, it does not matter, whether year is at the beginning or at the end.
UPDATE: Even if you sort string-wise you are fine, so sort @dates does the job.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sorting dates in YYYYMMDD format
by salva (Canon) on Jul 04, 2013 at 07:11 UTC | |
by QM (Parson) on Jul 10, 2013 at 09:10 UTC | |
by Anonymous Monk on Jul 10, 2013 at 13:13 UTC | |
by QM (Parson) on Jul 11, 2013 at 08:21 UTC | |
by Anonymous Monk on Jul 11, 2013 at 10:15 UTC |