|
Test
Your EQ #145 Answer
|
Answer
10
This
is a special case of the Schwartzian Transform known as
a "packed-default sort," which eliminates the custom sort
subroutine altogether.
Generally, any technique that allows you to use the native
comparison of the sort function will be the best performer,
especially on large data sets. Remember, any inefficiencies
in the pre- and post-processing are O(N), while the sort
itself is O(N log N).
See www.effectiveperl.com/recipes/sorting.html
and www.sysarch.com/perl/sort_paper.html
for some discussion. Search for "packed-default sort"
in the latter.
Contributor:
Dave Tweed
Published: August-2002