in reply to Re: Re: Sorting a hash
in thread Sorting a hash
you may want to move your sort code into a subroutine and just call sort with the sub name instead of direct code, make your code easier to read since the code in the sort is getting long%numeric = (mac_number => 1, generic_code => 1); foreach $record ( sort { if($numeric($sort_by)) { return $a->{$sort_by +} <=> $b->{$sort_by} } else { return $a{$sort_by} cmp $b{$sort_by} } +} @claim_records ) { print STDOUT $record->{'claim_number'}, "\n"; }
|
|---|