Imtiaz Ahmad wrote:
> 
> Hi-

Hello,

> Lets say if we have an ARRAY @array_1 with following values:
> 
> 31472  468X60  1.49
> 31473  468X60  2.18
> 31488  180X60  1.39
> 31476  468X60  1.58
> 33472  120X60  2.49
> 32473  468X60  4.38
> 
> ################################################################
> for($i=0;$i<$#sql_results1;$i++)
>         {
>         ($campid,$szname,$avg) = split(/\s\|\s/,$sql_results1[$i]);
>       $campid =~ s/\|//g;
>       $szname =~ s/\|//g;
>       $avg    =~ s/\|//g;
>       push @array_1, [$campid, $szname, $avg];
>       }
> ################################################################
> And I want to sort @array_1 by szname which is the second column.
> How do I do it so that it includes all the column when sorting.
> 
> So the end result should be:
> 33472  120X60  2.49
> 31488  180X60  1.39
> 31472  468X60  1.49
> 31473  468X60  2.18
> 31476  468X60  1.58
> 32473  468X60  4.38
> 
> thanks.
> 
> Can't use ORDER BY clause in SQL because of some limitation of SQL --- And
> other way is
> going to require significant amount of work.



chomp( my @array = <DATA> );

print "$_\n" for @array;
print "\n";

my @sorted = map { (split/\0/)[1] }
             sort
             map { "@{[(split)[1,0,2]]}\0$_" }
             @array;

print "$_\n" for @sorted;

__DATA__
31472  468X60  1.49
31473  468X60  2.18
31488  180X60  1.39
31476  468X60  1.58
33472  120X60  2.49
32473  468X60  4.38



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to