in reply to Sorting hash of hash of hash by values
You don't seem to be far off, but I hope you didn't fall into the trap of trying to sort the hash itself. Hashes can't be sorted, but arrays or lists made from their keys.
foreach $batch ( keys %{$hash{$host}} ) { my @runs= keys %{$hash{$host}{$batch}; @runs= sort { $hash{$host}{$batch}{$a}{start} <=> $hash{$host}{$bat +ch}{$b}{start} } @runs; foreach $run (@runs) { ...
Naturally you can compress this into one line and remove the need for @runs, but I wanted to show explicitly what I was doing
Oh and it is untested. Wouldn't suprise me if I had made a silly mistake somewhere
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sorting hash of hash of hash by values
by legendx (Acolyte) on Jul 07, 2011 at 21:45 UTC | |
by jethro (Monsignor) on Jul 08, 2011 at 08:56 UTC | |
by legendx (Acolyte) on Jul 08, 2011 at 14:47 UTC |