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


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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.