read `ENG.txt`:

#ANAG(S,A)
ANAG:=proc(S,A) local S1,Ss,T,B:

S1:={}:

for Ss in S do

 if nops(Ss)=A then
    
  S1:=S1 union {sort(Ss)}:
   T[sort(Ss)]:={}:
 fi:
od:


for Ss in S do

 if nops(Ss)=A then
    
   T[sort(Ss)]:
 fi:
od:
end:






