in reply to Re: Array Sorting Trouble
in thread Array Sorting Trouble

Due to your usage of map, you lose the information which keys are in the top $X. You have left are the values, but the example output did show the key names.

Abigail

Replies are listed 'Best First'.
Re: Re: Array Sorting Trouble
by fglock (Vicar) on Oct 02, 2002 at 14:00 UTC

    You are right. Here is a version that saves the keys:

    %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->[0] <=> $a->[0] } map { [$my_array{$_}[$column], $_] } keys %my_array; print $column+1, ": $a[0][1]=$a[0][0], $a[1][1]=$a[1][0] \n"; }