Creating sorted input files for reducer