alnico has asked for the wisdom of the Perl Monks concerning the following question:
I am able to sort by keys using...%HoA = ( part1 => [ 'Sc', 'John', 'Jacob', 'Jingle' ], part2 => [ 'Sc', 'Diffie', 'Whitman' ] jpart3 => [ 'Mo', 'Diffie', 'Duffy' ] );
and I am able to sort by value using...sub sort_keys_ascending{ sort keys %HoA }
The problem arises when I want to sort by value, then by the key itself...my $href = \%HoA; sub sort_typeparm_ascending{ sort{ $href->{$a}[$col_id] cmp $href->{$b}[$col_id] } keys %data }
Do you fellas know if it's possible to do it in this format or am I completely on the wrong path? I can't find any info on how to do this. Thanks in advance, Dekesub sort_typeparm_descending{ sort{ $href->{$b}[ 0 ] cmp $href->{$a}[ 0 ] || ????? KEY{$b} ????? cmp ????? KEY{$a} ????? } keys %data; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I sort a hash of arrays by value THEN by key?
by halley (Prior) on Aug 29, 2005 at 16:17 UTC | |
|
Re: How do I sort a hash of arrays by value THEN by key?
by salva (Canon) on Aug 29, 2005 at 16:56 UTC |