in reply to Re: Re: Sorting a hash
in thread Sorting a hash

ahhh. I see, you are trying to sort by a field in claim records... hmmm... can you keep track of which records are numeric? then you could do...
%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"; }
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
                - Ant