in reply to Re: sorting on multiple columns using Data::Table?
in thread sorting on multiple columns using Data::Table?
Running it, I get the error message: Row index out of range 0..-1use 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";
Thanks again, cypress
(And I did make a slight data typo in my original post.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: sorting on multiple columns using Data::Table?
by olus (Curate) on Feb 25, 2008 at 19:47 UTC |