@sorted_keys = sort { $a <=> $b } keys %hash; #use { $a <=> $b } for numerical sorting #use { $a cmp $b } for string sorting foreach(@sorted_keys) { print $hash{$_}; }