I have found the following Python code from Stackoverflow which opens a file called sort.txt, and then sorts the the numbers contained in the file.
The code works perfect. I was wondering how I could then save the sorted data to another text file. Every time I try, the saved file is shown empty.
Any help would be appreciated.
I would like the saved file to be called sorted.txt
with open('sort.txt', 'r') as f:
lines = f.readlines()
numbers = [int(e.strip()) for e in lines]
numbers.sort()