my @temp = map { $_ => $h{$_} } sort { $a <=> $b } keys %h; %h = @temp[0,1];