in reply to Re: HoH Sorting by value
in thread HoH Sorting by value
Probably you want a hash with ss_number as the key and the value as either an array ref or hash ref with all the values associated with that ss_number. E.g.
Anyway, one easy way to get what you want is like this (at least on Unix (using the latter data structure:$myhash{'555236801'} = [3035, 2]; or $myhash{'555236801'} = { empno => 3035, years => 2 };
open SORTEDOUT, "|sort +2" or die "cannot open sort: $!\n"; for (keys %myhash) { print SORTEDOUT $_, " ", $myhash{$_}{empno}, " ", $myhash{$_}{year +s}, "\n"; } close (SORTEDOUT) or die "Error on sort: $!\n";
|
|---|