my %uniq; for ( keys %hash ) { my $reordered_key = join sort split ''; $uniq{$reordered_key} += $hash{$_}; } # still untested