Requirements
You are given with a large data set, every line of the file has one word.
You need to read the file and group anagram words, consist of same characters in different order (i.e. except, expect).
You need to keep the insertion order, however, sort the anagram words lexicographically among each other.
If a word has no anagram word in the file, do not write it to the output file.
Focus on maintainability, scalability, performance.
No need for extensive error handling.
GIVEN INPUT
who
how
except
expect
tree
purse
EXPECTED OUTPUT
how who
except expect