http://qs321.pair.com?node_id=107588


in reply to Re: Re: Sorting characters within a string
in thread Sorting characters within a string

Building the hash programmatically would be ani nteresting brain teaser.

Here is the worst way to do it:
my @strings = (grep /[acgmt]{2}/, ('aa' .. 'tt'), grep /[acgmt]{3}/, ('aaa' .. 'ttt'), grep /[acgmt]{4}/, ('aaaa' .. 'tttt')); my %sort_cache; for my $key (@strings) { $sort_cache{$key} = join '',sort split('',$key); }

Hey, don't take this seriously ;-) it does the job but it's so inefficient it's scary.
Guillaume