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;

I believe that will do it. See if that gets you going.

James


-- 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