@sorted = sort keys %h; foreach ( @sorted ) { ... $h{$new} = $new;