# ------------------------------------------------- package Mlh::Callbacks; sub SortTableByField {    my ($table, $id) = @_;    # sort @::Data by column $id with Schwartzian Transform    @::Data = map { $_->[1] }    sort { $a->[0] cmp $b->[0] }    map { [ lc($_->[$id]), $_ ] }    @::Data;    # update table according to new order of @::Data    &UpdateTable($table, \@::Data); } # SortTableByField # -------------------------------------------------------- sub UpdateTable {    my ($table, $data) = @_;    $table->delete('all', '');    foreach my $i (0..$#$data) { &TableInsertRow($table, $data->[$i]);    } # foreach } # UpdateTable # --------------------------------------------------------- package Mlh::Widgets; sub Table {    my ($frame, $headline, $browseCmd, $background, %options2) = @_;    my %options = (-header => 1, -background => '#ffffff', -gap => 10,   -selectmode => 'single',   -font => $Mlh::Config::StandardFont,);    $options{-browsecmd}        = $browseCmd if (ref $browseCmd);    $options{-background}       = $background || '#ffffff';    $options{-selectbackground} = $Mlh::Config::Background;    my $hl = $frame->Scrolled('MyHList', -scrollbars => 'osoe',      -columns => scalar(@$headline),      %options, %options2);    my $styleButton = $hl->ItemStyle('window');    $styleButton->configure(-pady => 0, -padx => 0);    foreach my $i (0..$#$headline) { my $button = $hl->Button  (-text => $headline->[$i], -relief => 'flat',   -font => $Mlh::Config::FixedFont,   -activebackground => $Mlh::Config::Background,   -command => [ \&Mlh::Callbacks::SortTableByField, $hl, $i ],   ); $hl->header('create', $i++, -itemtype => 'window',    -widget => $button, -style  => $styleButton);    } # foreach    return $hl; } # Table # ------------------------------------------------ package Tk::MyHList; use base qw(Tk::Derived Tk::HList); Construct Tk::Widget 'MyHList'; sub Populate {    my ($self, $args) = @_;    my $rightClick = delete $args->{-rightClick}; ref($rightClick) and $self->bind('', $rightClick);    $self->SUPER::Populate($args); } # Populate # ============================================