# Sort so that alpha keys come first, then numerics map $_->[1], sort { $a->[0] <=> $b->[0] or $a->[0] ? $a->[1] <=> $b->[1] : $a->[1] cmp $b->[1] } map [(/[a-z]/i ? 0 : 1), $_], keys %hash;