in reply to Sort array according to a value in each element?

@arr = (); $arr[0][0]=2; $arr[0][1]=2; $arr[1][0]=0; $arr[1][1]=1; $arr[2][0]=1; $arr[2][1]=3; $arr[3][0]=1; $arr[3][1]=2; foreach $val (sort {$b->[1] <=> $a->[1]} @arr) { print join("|", @{$val}) . "\n"; }

You can also implement this using hashes.

Edit by castaway, swapped pre tags for code tags

Replies are listed 'Best First'.
Re: Re: Sort array according to a value in each element?
by mrpeabody (Friar) on May 24, 2004 at 23:33 UTC
    At first I thought this was an attempt at symbolic references, but upon further inspection it doesn't even compile. Either you're completely clueless about Perl's array syntax, or you've misused the markup tags somehow.