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

I want to sort the keys of a hash stored within an object. If I create a user defined cmp function for my sort, it only gets the values $a and $b. Within this cmp function how do I access the $self of the object?
# object $self={ hash_ref=>{item1=>'value1',item2=>'value2'} } # cmp funtion sub byvalue { #instead of $a<=>$b; #something like $self->{hash_ref}->{$a}<=>$self->{hash_ref}->{$b}; #how do I access $self in this function? } # object's sort function sub sort_hash_ref_keys_by_value { my $self=shift; my @keys=sort byvalue keys(%{$self->{hash_ref}}); }