I have a file with each line like
Name1 name2 name3
I can read it in line by line, split each line, process the line and output the processed line by line.
However I would like to read the whole file in, sort it by the middle column, then output the whole sorted file in the same format the input was in.
My first attempt splits each line as it is read in to make a list of tuples, then sorts using key= , then rejoins each tuple and outputs line by line.
Is there a more pythonic way of doing this?