Rewrite sorter generator.