I don't have all the required Perl versions to test here, but the "( @arr ) = ( listelement, ... )" construction looks suspiciously ambiguous. Have you tried dropping the brackets from the left hand side of the list-to-array assignments?
That doesn't make any difference, however making both @sortkey and @names lexicals does make a difference with 5.8.8 but not blead (they segfaulted in different places in the original code.)