basically I have a bunch of files containing domains. I\'ve sorted each individual file based on its TLD using .sort(key=func_that_returns_tld)
now that I\'ve done that
Another option (again, only if all your data won't fit into memory) is to create a SQLite3 database and do the sorting there and write it to file after.