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
Unless your file is incomprehensibly huge, it will fit into memory.
Your pseudo-code is hard to read. Please indent your pseudo-code correctly. The final "loop by reading next line" makes no sense.
Basically, it's this.
all_data= []
for f in list_of_files:
with open(f,'r') as source:
all_data.extend( source.readlines() )
all_data.sort(... whatever your keys are... )
You're done. You can write all_data
to a file, or process it further or whatever you want to do with it.