I have very little experience with perl. I have a plx/tmpl page that displays a data table based on a @records array. I am able to sort the array by a subkey thanks to code from KevinADC.
I want to create links out of the column headers then change the sort order based on what the user clicks (ascending/descending). The links change the 'sort' querystring value. I am able to get the querystring with:
I coded the tmpl file to change the link when the user clicks it, that part works fine.
I tried this in my plx page but it does not do anything:
Any ideas?
I want to create links out of the column headers then change the sort order based on what the user clicks (ascending/descending). The links change the 'sort' querystring value. I am able to get the querystring with:
Code:
my $sortvar = param('sort');
I coded the tmpl file to change the link when the user clicks it, that part works fine.
I tried this in my plx page but it does not do anything:
Code:
if ($sortvar == '1')
{
my @records = map { $_->[0] }
sort { $b->[1] cmp $a->[1] }
map {(my $date = $_->{COMPDATE}) =~ s/<font color="#FF0000">//;
my ($d,$m,$y) = split(/\s+/,$date);
$d = $d<10 ? "0$d" : $d;
$m = $month{lc substr $m,0,3};
[$_,"$y$m$d"]} @records;
}
elsif ($sortvar == '2')
{
my @records = map { $_->[0] }
sort { $a->[1] cmp $b->[1] }
map {(my $date = $_->{COMPDATE}) =~ s/<font color="#FF0000">//;
my ($d,$m,$y) = split(/\s+/,$date);
$d = $d<10 ? "0$d" : $d;
$m = $month{lc substr $m,0,3};
[$_,"$y$m$d"]} @records;
}
Any ideas?