in reply to Re: Sorting hash of hash of hash by values
in thread Sorting hash of hash of hash by values

Hey thanks! that worked. I was able to sort by the $batch 'duration' values
I was using  sort { $hash{$host}{$batch}{$run}{$a}{start} <=> $hash{$host}{$batch}{$run}{$b}{start} } instead and it wasn't working.

Why does hash{$host}{$batch}{$a}{start} <=> $hash{$host}{$batch}{$b}{start} work when I am not specifying the $run? Is it because Perl puts the two elements it wants to compare (which is the $run) into the special variables $a and $b?

Replies are listed 'Best First'.
Re^3: Sorting hash of hash of hash by values
by jethro (Monsignor) on Jul 08, 2011 at 08:56 UTC

    Yes, $a and $b are aliases to values that get compared. Even if it were not it wouldn't make sense to add more dereferencing to a hash structure than there is depth.

    Just out of curiosity: Why did you write $a and $b into your code if you didn't know that?

      I guess I was not 100% clear on how it worked