sub f{my%h=@_;for(values %h){for(@$_){$h{$_}=[]if!$h{$_}}} print join(', ',sort{(grep /^$b$/,@{$h{$a}})?1:-1}keys%h)}