in reply to Re: Sorting a two-dimensional array by two columns
in thread Sorting a two-dimensional array by two columns

Maybe I'm wrong but I think you've done a Guttman-Rosler Transform here, not a Schwartzian Transform. You have combined the two values to be sorted into a single string which can be lexically sorted rather than keeping them separate and doing a sort {$a->[0] <=> $b->[0] || $a->[1] <=> $b->[1]}. From what I've read the GRT usually uses pack to combine the sort keys but sprintf looks just as effective here.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^3: Sorting a two-dimensional array by two columns
by GrandFather (Saint) on Jul 05, 2006 at 23:33 UTC

    Heh, looks like you are right. I didn't know about GRT, but it seemed like an obvious clean up of the code and possibly faster too.

    I was pleased with the reply because it's the first time I've "clean room" coded a ST (or possibly a GRT) - I didn't look at an example. I progress. :)


    DWIM is Perl's answer to Gödel
      It looks like you've re-invented the GRT without any reference to the original authors. Perhaps GRT could now be for GRandfaTher method :)