in reply to Re: Re: HoH Sorting by value
in thread HoH Sorting by value

Take broquaint's answer, remove the assignment, add a loop and a print. Job done.

Or do you just want the code:

my %hash; while (<DATA>) { my @data = split; $hash{$data[0]}->{employee_number} = $data[1]; $hash{$data[0]}->{years_employed} = $data[2]; } foreach (sort { $hash{$a}->{years_employed} <=> $hash{$b}->{years_employed} } keys %hash) { print "$_ $hash{$_}->{employee_number} $hash{$_}->{years_employed}\ +n"; }; __DATA__ SS123 EMP123 3 SS234 EMP124 2 SS456 EMP125 1
prints
SS456 EMP125 1 SS234 EMP124 2 SS123 EMP123 3

rdfield