in reply to sort by hash with existence check
First, you really want to use Schwartzian Transform and of course you can check for existence, in this case you check for defined()ness and you must specify the behaviuor: is 'nis-1' greater than 'nis' or less than or what? I assume 'nis-1' and 'nis' must be equal
--sub sortHash { my $hash = shift; [ map { $_->[0] } sort { $a->[1] cmp $b->[1] or defined( $a->[2] ) and defined( $b->[2] ) and $a->[2] <=> $b->[2] } map { [ $_ , split /[-,]/ ] } keys %$hash ] }
|
|---|