for (sort {$a <=> $b} keys %dbmhash) { #do something with the value which is $dbmhash{$_} }