words = ['eat', 'tea', 'tan', 'ate', 'nat', 'bat']
result = []
used = []
for word in words:
if word in used:
continue
group = []
for other in words:
if sorted(word) == sorted(other):
group.append(other)
used.append(other)
group.sort()
result.append(group)
result.sort()
print(result)