Hi, I'm having real trouble with custom sorting an array. I have written an object to represnt a simple hash.. one of the subroutines that it provides is size(). Thus I can say $myset->size() to find out how many elements it contains.
So I have an array of these set objects and I want to sort it so that the array is in size order. I access the array as a reference, thus I wrote something like the following:
@sorted = sort {$$setarray[$a]->size() <=> $$setarray[$b]->size()} @$s +etarray;
However, this gives errors about "cannot call size() on uninitialised value", yet if I write print $$setarray[0]->size() the correct size is returned for that set.
I tried then to write to sort in different ways and this resulted in errors stating something about not being able to call size() on an unblessed reference... perhaps I've made a mistake in my object??
Can someone help me... I think I just can't write the custom sort subroutine properly??
Thanks,
____________In reply to Problems with custom sort by arunhorne
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |