At 03:49 PM 2/18/2004, James Edward Gray II wrote:
>On Feb 18, 2004, at 1:58 PM, Smith Jeff D wrote:
>
>>I am trying to sort a hash of arrays that is similar to the example below.
>>I have a hash of arrays that I want to sort, first by the first element of
>>the array, then by the key to the hash and don't care about other elements
>>of the array (for sorting and without regard to case.
>>
>>%HofA = (orange=>['ZZZ', 'ANDY'],
>>           red=>['AAA', 'AL'],
>>           blue=>['mmm','Betty'],
>>           yellow=>['aaa', 'ZEUS'],     
>>           green=>['DDD','Mary Joe']
>>           violet=>['MMM','Hugo']
>>           );
>
>my @ordered_keys = sort { $HofA{$a}[0] cmp $HofA{$b}[1]
>                                           ||
>                                           $a cmp $b } keys %HofA;

Ok, I'll bite, why this:

>my @ordered_keys = sort { $HofA{$a}[0] cmp $HofA{$b}[1]

and not this:

>my @ordered_keys = sort { $HofA{$a}[0] cmp $HofA{$b}[0]


I would have guessed you want the same array element in the 2 comparison values.

-Mark




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to