use strict; use warnings; my %hash = map { $_ => 1 } qw/987-665-888 456-123-000 000-000-000 123-456-789/; print "$_\n" for sort { $a =~ s/-//gr <=> $b =~ s/-//gr } keys %hash;