|
how to (really) sort a hash by key in Perl
lets I have a hash:
%hash=(
'2004' => "red",
'2006' => "blue",
'2005' => "green"
);
how do I sort it by key? i don't want to print it out sorted, only sort it
using this:
@keys = sort keys %hash;
will NOT work, because @keys now contain only the keys
why is it so fucking hard to get this:
%hash=(
'2004' => "red",
'2005' => "green",
'2006' => "blue"
);
|