in reply to how to do effective sort in perl

As other have alluded, there are several paths to optimization.

Do you want it to run faster?

Do you want to use less code?

Do you want it to be more readable, maintainable, portable, or more robust?

glob or similar will be less code. What you've given (other than the lack of codetags) is almost as good as you can do for balancing all of the criteria above.

Incidentally, IIRC Perl has builtin optimizations for the following sort subs:

{$a cmp $b} # default {$b cmp $a} {$a <=> $b} {$b <=> $a}
These are the most common. So using any one of these should be indistinguishable from the default (no sort sub) case.

-QM
--
Quantum Mechanics: The dreams stuff is made of