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'] ); comes out like this: AAA, red, ZEUS aaa, yellow, AL DDD, green, Mary Joe MMM, blue, Betty, MMM, violet, Hugo ZZZ, orange, ANDY The following snippet doesn't sort the stuff the way I want--need some help.... Thanks in advance. Jeff Smith # BEGINNING SNIPPET: use strict; use warnings; my %testhash = (); (my $value, my $key) = ''; %testhash = (orange=>['ZZZ', 'ANDY'], red=>['AAA', 'AL'], blue=>['MMM','Betty'], yellow=>['AAA', 'ZEUS'], green=>['DDD','Mary Joe'] violet=>['MMM','Hugo'] ); while (($key, $value) = each %testhash) { my @array = ($value->[0], $key, $value->[1]); my @newarray = sort @array; print "array is @newarray\n"; } ####End of snippet