I require a lot of help on reading and sorting files

And before I go posting away about my code, I was wondering if there is actually someone here who knows programming on python and is willing to help. Long story short, I am trying to write a code which reads a file and then sorts and and then writes it out to another file. I am give more details after if there is someone who is willing to help.

Thanks a lot in advance!


  • I haven't worked in Python recently, and I am far from an expert on it, but I do know that what you are trying to do is not that complicated in Python. I should be able to help you if you paste your code, or you can message it to me too.

    To start off, your program can be divided into a few steps, such as:

    i) read all the lines from the input file into a list of strings

    ii) sort the list using a simple one-line library function or in-built sort operator, as the case may be for Python

    iii) after you have sorted the file, you write out the sorted list to the new file.

    Apart from that, you also have to open the relevant files before reading and writing to them, and then close their handles after you are done with them.

    The above comment assumes you want to sort the file according to lines.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion