Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting array of array 1

Status
Not open for further replies.

KeziaKristina

Programmer
Nov 1, 2002
13
ID
I have problem with sorting an array of array.
@array = (
[200,3],
[100,5],
[250,6],
[700,5],
[370,4],
);
I want to sort descanding the first elemen of array on each index.
The result is like this :
@array = (
[700,5],
[370,4],
[250,6],
[200,3],
[100,5],
);
Thanks..
 
Code:
@new = sort { $b->[0] <=> $a->[0]} @array;

just a fluke method ;) ---
cheers!
san
pipe.gif


&quot;The universe has been expanding, and Perl's kind of been expanding along with the universe&quot; - Larry Wall
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top