in reply to Re^4: How would I sort a two-dimensional array by multiple columns?
in thread How would I sort a two-dimensional array by multiple columns?

While I like your solution, FunkyMonk's routine could be made to sort on all elements of an array by changing its arguments:

my $sorted = FunkyMonkSort($unsorted, 0..$#$unsorted);

Your code meets the specification to sort a 2D array where each element in every row is compared.

FunkyMonk's code solves a different problem--sort a 2D array by an arbitrary subset of elements in each row.

I spent a while looking for the "bug". There really isn't a bug, it's just that you interpreting the spec differently than FunkyMonk did.

BTW, I like the way that you called attention the the fact the NetWallaSort() is a sort function, and gets $a and $b automagically.


TGI says moo

  • Comment on Re^5: How would I sort a two-dimensional array by multiple columns?
  • Download Code

Replies are listed 'Best First'.
Re^6: How would I sort a two-dimensional array by multiple columns?
by NetWallah (Canon) on Mar 16, 2008 at 00:35 UTC
    TGI (++)- Agreed to all your points.

    I had /msg'd FunkyMonk (also ++) that I had misread the OP's requirement.

    I now publicly post that his post was NOT buggy, based on what the OP said he wanted, and his "@_" was indeed what he intended (after his update).

         "As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom