in reply to sort by a multiple columns

How is this?
my @arr4 = sort { $a->[0] cmp $b->[0] } @un_sorted; print "Mutli-Dimensional Array\n"; for my $i ( 0 .. $#arr4) { for my $j (0 .. $#{$arr4[$i]}) { print "$arr4[$i][$j]\t"; } print "\n"; }

Edited by Chady -- replade <pre> with <code>

Replies are listed 'Best First'.
Re^2: sort by a multiple columns
by Roy Johnson (Monsignor) on Sep 09, 2004 at 12:56 UTC
    Bad on several fronts: You are doing an alphabetical comparison of the first element only; you didn't use <code> tags around your code; and you misspelled "multi". It's generally more Perlescent to iterate over the arrays rather than their indexes.

    I don't mean to be discouraging; on the contrary, I hope you will find this assessment helpful. Don't give up. Welcome to the Monestary.


    Caution: Contents may have been coded under pressure.