#!perl -nl push@{$h{join'',sort/./g}},$_;END{map{s/. //s;print if/ /}sort map"@{[chr@$_,sort@$_]}",%h}