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

Hi Funk, I like your solution and I am able to get it working fine in test, however in my existing code I will be passing a list of array references within an array to the routine (@unsorted).

For example here's the part of my code where I am loading the array:

while ( @row = $sth->fetchrow_array ) { push @x, [ @row ]; }
$rindex = 0; $i = 1; do { foreach ( @columns ) { if ( $_ <= $qstart_column - 2 ) { $unsorted[$rindex][$_] = $x[$i][$_]; } else { $unsorted[$rindex][$_] = $x[$i][$_ - $nun_of_questions +]; } } $rindex += 1; $i += $nun_of_questions; } while ( $i <= $#x );

Right now when run your code in my code I get the following:

Use of reference "ARRAY(0x10b5810)" as array index at /home/dmathis/qw +est_qqs/transpose-qqs-dev line 367. Use of reference "ARRAY(0x10b5810)" as array index at /home/dmathis/qw +est_qqs/transpose-qqs-dev line 367. Use of uninitialized value in numeric comparison (<=>) at /home/dmathi +s/qwest_qqs/transpose-qqs-dev line 367. Use of uninitialized value in numeric comparison (<=>) at /home/dmathi +s/qwest_qqs/transpose-qqs-dev line 367. ................ ................ ................

I just need to figure out what to alter in your code to handle my array.

Best Regards