use Data::Table; $header[0] = "NAME"; $header[1] = "NUMBER"; $data[0][0] = "Mary"; $data[0][1] = 3; $data[1][0] = "John"; $data[1][1] = 2; $data[2][0] = "John"; $data[2][0] = 4; $data[3][0] = "Mary"; $data[3][1] = 2; $table = new Data::Table ($data, $header, 0); # TRIPLETS, FIRST PARAM IS COLUMN INDEX, SECOND IS NUMERICAL VALUE/ # NON-NUMERICAL, THIRD IS ASCENDING/DESCENDING SORT $table->sort(0, 1, 0, 1, 0, 0); # RECONSTITUTE ARRAY $data[0][0] = $table->elm(0,0); $data[0][1] = $table->elm(0,1); $data[1][0] = $table->elm(1,0); $data[1][1] = $table->elm(1,1); $data[2][0] = $table->elm(2,0); $data[2][1] = $table->elm(2,1); $data[3][0] = $table->elm(3,0); $data[3][1] = $table->elm(3,1); print "$header[0]\t$header[1]\n\n"; print "$data[0][0]\t$data[0][1]\n"; print "$data[1][0]\t$data[1][1]\n"; print "$data[2][0]\t$data[2][1]\n"; print "$data[3][0]\t$data[3][1]\n";
Running it, I get the error message: Row index out of range 0..-1

Thanks again, cypress

(And I did make a slight data typo in my original post.)


In reply to Re^2: sorting on multiple columns using Data::Table? by cypress
in thread sorting on multiple columns using Data::Table? by cypress

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.