in reply to Sort problems

How, with this many solutions, did I immediately gravitate toward the stupidest?

My plan was to make a copy of the list, and then pad out all the numbers with leading zeroes to make them compare naturally under regular alphebetization.

I felt that it was a stupid plan the moment it came up, but the stupidest? Woe is me...

for(split(" ","tsuJ rehtonA lreP rekcaH")){print reverse . " "}print "\b.\n";

Replies are listed 'Best First'.
Re^2: Sort problems
by AnomalousMonk (Archbishop) on Dec 02, 2008 at 13:07 UTC
    Your "stupid plan" is the heart of the Guttman-Rosler Transform (GRT; see Advanced Sorting - GRT - Guttman Rosler Transform). This approach is based on the fact that using the default lexicographic sorting of sort is faster than using a sort subroutine block, so multi-key GRT sorts will tend to outstrip ST sorts as the array size grows beyond some threshold.

    Just think, if you had come up with this stupid idea a few years ago, your own name might now be immortalized in the annals of Perl!

    The original paper is A Fresh Look at Efficient Perl Sorting, also linked by demerphq's link above.

      Just think, if you had come up with this stupid idea a few years ago, your own name might now be immortalized in the annals of Perl!

      Maybe, but I'd say not likely. As it happened, the technique was named for the two fellows who extensively analyzed it and wrote a paper about it, but not for the guy who first (as far as can be discerned from the Historical Records) came up with the idea, Michal Rutka. Here's the Usenet message.

      Between the mind which plans and the hands which build, there must be a mediator... and this mediator must be the heart.