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
|
|---|
| 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 |