Oops, I thought he wanted to group by quantity. To group by presence/absence (presence first), it's simplest to solidify the concept into values that can be compared with <=> or cmp. Let's pick zero for presence and one for absence (since zero comes before one).
my $pro_products = $products{Cat}{Pro}; sort { $pro_products->{$a}{Qua} ?0:1 <=> $pro_products->{$b}{Qua} ?0:1 || $a cmp $b } keys %$pro_products
Update: Down below, L~R picked "A" and "B" instead of 0 and 1. Same idea.
In reply to Re^3: Complex conditional sort
by ikegami
in thread Complex conditional sort
by Zhris
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |