Feel free...but I've spent hours on this. Here is my test script, note the section that works and does not work.
use Wx; package MyFrame; use strict; use vars qw(@ISA); @ISA = qw(Wx::Frame); use Wx qw(:everything); my %hash = (); my $sort = 'asc'; my $acol = 0; sub new { my( $class ) = shift; my( $this ) = $class->SUPER::new( undef, -1, $_[0], [ @_[1, 2] ], [ @_[3, 4] ] ); $this->{LISTCTRL} = Wx::ListCtrl->new( $this, -1, wxDefaultPositio +n, wxDefaultSize, wxLC_REPORT ); $this->{LISTCTRL}->InsertColumn( 0, "Column 1" ); $this->{LISTCTRL}->InsertColumn( 1, "Column 2" ); $this->{LISTCTRL}->InsertColumn( 2, "Column 3" ); # control hidden to speed up insertion $this->{LISTCTRL}->Show( 0 ); my( $id ); my( $elements ) = 5; foreach ( 1 .. $elements - 1 ) { # WORKS #my $data = int(rand(100)); #my $data2 = int(rand(100)); #my $data3 = int(rand(100)); # DOES NOT WORK my $data = "STRING: " . int(rand(100)); my $data2 = "STRING: " . int(rand(100)); my $data3 = "STRING: " . int(rand(100)); $id = $this->{LISTCTRL}->InsertStringItem( $_, $data ); $this->{LISTCTRL}->SetItemData( $id, $data ); $this->{LISTCTRL}->SetItem( $id, 1, $data2 ); $this->{LISTCTRL}->SetItem( $id, 2, $data3 ); $hash{$data}{0} = $data; $hash{$data}{1} = $data2; $hash{$data}{2} = $data3; } $this->{LISTCTRL}->Show( 1 ); my( $item ) = Wx::ListItem->new; $this->{LISTCTRL}->SetColumnWidth( 0, wxLIST_AUTOSIZE ); $this->{LISTCTRL}->SetColumnWidth( 1, wxLIST_AUTOSIZE ); $this->{LISTCTRL}->SetColumnWidth( 2, wxLIST_AUTOSIZE ); my( $topsizer ) = Wx::BoxSizer->new( wxVERTICAL ); $topsizer->Add( $this->{LISTCTRL}, 2, wxGROW ); $topsizer->Add( $this->{LOGWINDOW}, 1, wxGROW ); $this->SetSizer( $topsizer ); $this->SetAutoLayout( 1 ); use Wx::Event qw( EVT_LIST_COL_CLICK ); EVT_LIST_COL_CLICK( $this, $this->{LISTCTRL}, \&OnSort ); $this } sub Cmp { my( $f, $s ) = @_; my( $i1, $i2 ) = ( $hash{$f}{$acol}, $hash{$s}{$acol} ); #print "$f => $s\n"; #print "$i1, $i2\n"; if ($sort eq 'asc') { $i1 < $i2; } elsif ($sort eq 'desc') { $i1 > $i2; } } sub OnSort { my( $this, $event ) = @_; $acol = $event->GetColumn; # use Data::Dumper; # print Dumper(%hash); if ($sort eq 'asc') { $sort = 'desc'; } else { $sort = 'asc'; } $this->{LISTCTRL}->SortItems( \&Cmp ); } package MyApp; use strict; use vars qw(@ISA); @ISA = qw(Wx::App); sub OnInit { my( $this ) = @_; my( $frame ) = MyFrame->new( 'wxPerl ListCtrl Test', 50, 50, 450, 34 +0 ); $frame->Show( 1 ); $this->SetTopWindow( $frame ); 1; } package main; my( $app ) = MyApp->new; $app->MainLoop;

In reply to Re^2: Determing "numeric value" of string? by Anonymous Monk
in thread Determing "numeric value" of string? by Anonymous Monk

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.