in reply to Array Sorting Trouble
%my_array=(Key_One=>["50","25","100","90"], Key_Two=>["35","18","110","72"], Key_Three=>["100","35","99","82"] ); $a_key = each %my_array; for $column (0 .. $#{$my_array{$a_key}}) { @a = sort { $b <=> $a } map { $my_array{$_}[$column] } keys %my_array; print $column+1, ": @a[0..1] \n"; }
output:
1: 100 50 2: 35 25 3: 110 100 4: 90 82
note on "each" function: When called in scalar context, returns only the key for the next element in the hash.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Array Sorting Trouble
by Abigail-II (Bishop) on Oct 02, 2002 at 13:51 UTC | |
by fglock (Vicar) on Oct 02, 2002 at 14:00 UTC |