in reply to hash sort problems

Hi Conal.

I can't imagine what you're trying to solve at the moment, and your link doesn't make it clearer - to me anyway. I suspect you want to sort a hash alphabetically and then perhaps upon various parts of it's value.

I tried your code:

my %server_hash = ( foo => {tag => 1}, bar => {tag => 10}, boot => {tag => 2}, snow => {tag => 8}, fish => {tag => 3}, adv => {tag => 1} ); foreach my $server ( sort {$server_hash{$a} cmp $server_hash{$b} && $server_hash{$a}{tag} <=> $server_hash{$b}{tag} } keys %server_hash) { print "$server:$server_hash{$server}{tag}\n"; }
and it gave me:
foo:1 adv:1 boot:2 fish:3 snow:8 bar:10
So I don't think that that's really what you're trying to do. Remember that you won't have several keys in the hash having the same value. Hashes don't do that.

How about you give us a sample hash? And the desired result: a list of sorted keys? If you do just want to sort the hash alphabetically, then you're almost there.

Jarich