thanks

this solved my problem

my @output_sorted = sort { (split /,/, $b)[0] <=>  (split /,/, $a)[0] }
@output;

thanks to all that helped
Jeff Pang <[EMAIL PROTECTED]> writes:
>
>>this is my friend's script
>>
>># collect all score
>>      my @output = ();
>>      my @old_output = ();
>>      foreach my $list (@bugkillers) {
>>        my ($id,$name) = split(/,/, $list);
>>        my $score =
>>$Bugs->getSCORE($showold,$id,$contest,$pContest,$groups);
>>        push(@output,"$score,$id,$name");
>>      }
>>      # print result
>>      foreach my $result (sort {$b <=> $a} @output) {
>>        my ($score,$id,$name) = split(/,/, $result);
>>        $html.=<<HTMLcode;
>>
>
>Hi,you have some mistakes when sorting the array.Because your array
>@output include the mixed elements,not just the numbers,so you get the
>bad result when sorting them with '<=>'.
>
>I would suggest you change the style of @output as:
>
>put @output,[$score,$id,$name];
>
>Now you can sort them by the array's NO.1 element (which is score) via
>accessing array's ref:
>
>for (sort {$b->[0] <=> $a->[0]} @output){
>  ...
>}
>
>
>Hope it helps and warning for no test.
>
>
>
>
>--
>Jeff Pang
>NetEase AntiSpam Team
>http://corp.netease.com



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to