sub f { %r=@_;map{$m{$_}={map{$m{$_}||={};$_=>1}@{$r{$_}}}}keys%r; reverse sort{$m{$b}{$a}-$m{$a}{$b}}keys%m; }