spx2 has asked for the wisdom of the Perl Monks concerning the following question:

If one uses a TableMatrix and needs to swap some rows for sorting purposes how does he do that ?

Replies are listed 'Best First'.
Re: Tk::TableMatrix swaping rows
by GrandFather (Saint) on Aug 30, 2007 at 10:25 UTC

    It looks like your best option is to use:

    $table->deleteRows(?switches?, index, ?count?)

    and:

    $table->insertRows(?switches?, index, ?count?)

    to manipulate the table rows or the two functions:

    $table->get(first, ?last?) $table->set(?row|col?, index, ?value?, ?index, value, ...?)

    to get previous contents and set new contents.


    DWIM is Perl's answer to Gödel
      this will leak and it will be slow. the best way is to directly manipulate the hash tied to the tablematrix widget. for images and tags extra work is required though.

      its too bad this wonderful module hasn't been "leak fixed" (I still have hopes though ;).

Re: Tk::TableMatrix swaping rows
by Anonymous Monk on Aug 30, 2007 at 10:04 UTC
    my @first = $table->get ... my @second = $table->get ... $table->set ... $table->set ...