updated source sorter to organize words by frequency and format them as valid json