develooper Front page | perl.beginners | Postings from April 2002

Sorting

Thread Next
From:
Imtiaz ahmad
Date:
April 29, 2002 15:00
Subject:
Sorting
Message ID:
E95AE238BE655441942C2139C83D00D0082AE958@MARS.us.iwon.com
Hi-

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.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About