http://www.perlmonks.org?node_id=818578

rethaew has asked for the wisdom of the Perl Monks concerning the following question:

Good day. I am in need of specifying a sorting method on an hash of hashes depending on the value of a variable. See this simplified code to see what I am trying to do.
if ($joe eq "numbers") {my $sortype='<=>';} if ($joe eq "letters") {my $sortype='cmp';} #then go on to work on the hash foreach $key (sort { $hoh{$a}->{value} $sortype $hoh{$b}->{value} } ke +ys %hoa) { blah; }
Obviously this code fails, but you can see what I am trying do to. I couldn't find anything like this searching the archives here. Thanks for your help.