in reply to Re^3: sorting keys in hash
in thread sorting keys in hash

horrible data structure ... :(

use warnings; use strict; use Data::Dump; my @unsorted =qw( Dec02 Jan02 May05 Dec01 Apr05 May15 ); my @sorted= sort datesort @unsorted; dd \@unsorted,\@sorted; my @months= qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); my %month_order; @month_order{@months} = 1..12; #dd \%month_order; sub datesort { my ($am,$ay) = $a =~ /(\w\w\w)(\d\d)/; my ($bm,$by) = $b =~ /(\w\w\w)(\d\d)/; return $ay <=> $by or $month_order{$am} <=> $month_order{$bm}; }

Cheers Rolf

( addicted to the Perl Programming Language)