in reply to Re: How can I access object data in a user defined sort cmp function?
in thread How can I access object data in a user defined sort cmp function?
This is not the same thing. You are sorting the objects themselves rather than a hash stored within an object.
This is a cheat because now $a and $b are object references, so they speak for themselves. If $a and $b are simply keys of a hash, the sort function has no clue to what object they belong.
However it is true, as others pointed out, that if I write the compare function in-line instead of a separate function, the in-line code sees the variables of the sub ( including the $self with which it was called ), so it has access to the object.