def sortkey(row):
    return row[5], row

def unwrap(key):
    sortkey, row = key
return row

FILE_LIST = map(file, ['foo.csv', 'bar.csv'])
input_iters = map(sortkey, map(csv.csvreader, FILE_LIST))
output_iter = map(unwrap, heapq.merge(*input_iters))
Yielding from sorted iterators in sorted order in Python?