S
Seansan
Joe,
thx for your help. The only way to do this is to duplicate the keys list
into an array? This doesnt seem smart for long lists. But it works! thx
Seansan
repost:
my %fields = (date=>1, email=>5, group=>9, url=>4, default=>1);
my $x = defined $fields{$FORM{SORT}} ?
$fields{$FORM{SORT}} : $fields{default};
sub ascending { $LIST{$a}[$x] cmp $LIST{$b}[$x] }
sub descending { $LIST{$b}[$x] cmp $LIST{$b}[$x] }
my @keys = $FORM{DOWN} ?
sort descending keys %LIST :
sort ascending keys %list ;
-Joe
thx for your help. The only way to do this is to duplicate the keys list
into an array? This doesnt seem smart for long lists. But it works! thx
Seansan
repost:
my $x=1;
if ($FORM{SORT} eq 'date') {$x=0;}
elsif ($FORM{SORT} eq 'email') {$x=5;}
elsif ($FORM{SORT} eq 'group') {$x=9;}
elsif ($FORM{SORT} eq 'url') {$x=4;}
my %fields = (date=>1, email=>5, group=>9, url=>4, default=>1);
my $x = defined $fields{$FORM{SORT}} ?
$fields{$FORM{SORT}} : $fields{default};
foreach (sort{$LIST{$a}[$x] cmp $LIST{$b}[$x];} keys(%LIST)) {
sub ascending { $LIST{$a}[$x] cmp $LIST{$b}[$x] }
sub descending { $LIST{$b}[$x] cmp $LIST{$b}[$x] }
my @keys = $FORM{DOWN} ?
sort descending keys %LIST :
sort ascending keys %list ;
-Joe