S
Seansan
Hi there,
I am trying to sort an array hash on values. I pass a FORM tag and resolve
it to the array position to sort on. (see code below). Is there an easy way
to sort ascending or descending based on a new FORM value like ASC or DESC?
How would I add this functionality? I know I have to swap $a and $b, but I
have no idea where or rather how to add this to my code....
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;}
foreach (sort{$LIST{$a}[$x] cmp $LIST{$b}[$x];} keys(%LIST)) {
(also posted alt.comp)
thx in advance, greets Seansan
I am trying to sort an array hash on values. I pass a FORM tag and resolve
it to the array position to sort on. (see code below). Is there an easy way
to sort ascending or descending based on a new FORM value like ASC or DESC?
How would I add this functionality? I know I have to swap $a and $b, but I
have no idea where or rather how to add this to my code....
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;}
foreach (sort{$LIST{$a}[$x] cmp $LIST{$b}[$x];} keys(%LIST)) {
(also posted alt.comp)
thx in advance, greets Seansan