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


in reply to Problems with custom sort

$a and $b are assigned the actual array elements, not the index to them.
So I believe that this will do what you want:
@sorted = sort {$a->size() <=> $b->size()} @$setarray;
---- kurt