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 ] }