my @sorted_keys = sort { $a <=> $b } keys(%foo); print join("\n",@hash{@sorted_keys})