For a variable number of second-dimension elements, try:
my @sorted = sort { my($ndx,$ret) = (0,0);
while(defined($a->[$ndx]) and defined($b->[$ndx])) {
last if $ret = ($a->[$ndx] <=> $b->[$ndx++]);
}
$ret;
} @Weights;
This keeps comparing elements from the second-dimension array elements
as long as they have values until one settles the comparison. Note that
the "last" statement leaves the loop on a boolean true, while the <=>
operator returns -1,0,or 1 respectively for less-than,equal,or
greater-than results; in Perl, 0,"", or undefined constitute FALSE,
while everything else is TRUE. (including NULL -- be warned =o)
Thus, as soon as any element evaluates to greater or less, the loop
exits, and the structure returns the <=> result to sort for ordering of
the rows.
Paul
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/