in reply to Sort Hash of Hash numerically
use warnings; use strict; my (%HoH) = ( "Smith" => { "house_type" => 'colonial', "head_count" => '5', }, "Jones" => { "house_type" => 'cape', "head_count" => '3', }, ); for (reverse sort { $HoH{$a}{head_count} <=> $HoH{$b}{head_count} } ke +ys %HoH) { print "$_ House Type: $HoH{$_}{house_type} Head Count: $HoH{$_}{he +ad_count}\n"; } __END__ Smith House Type: colonial Head Count: 5 Jones House Type: cape Head Count: 3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sort Hash of Hash numerically
by duelafn (Parson) on Jun 13, 2011 at 14:33 UTC | |
by toolic (Bishop) on Jun 13, 2011 at 14:50 UTC | |
|
Re^2: Sort Hash of Hash numerically
by Anonymous Monk on Jun 13, 2011 at 14:41 UTC |