I have a txt file containing 2 columns that are not ordered:
1 0.1
4 0.5
3 0.2
To order it for plotting, i found that i could that i could open the file and use zip function such as :
data=np.loadtxt(file)
x=data[:, 0]
y = data[:, 1]
x, y = zip(*sorted(zip(x, y)))
It works well but it doesn't actually modify the file and make the replacement to get the final output :
1 0.1
3 0.2
4 0.5