I created code that appends a list of 6 random numbers to a text file with some rules like 3 odds & 3 even, 2 odds & 3 even etc.
Is there any way to sort lists inside of a text file? For example:
If I have a text file like this:
[2, 3, 4]
[2, 4, 5]
[3, 1, 2]
[1, 3, 4]
[1, 2, 3]
and I want to arrange/sort it like this:
[1, 2, 3]
[1, 3, 4]
[2, 3, 4]
[2, 4, 5]
[3, 1, 2]
My solution so far (But I don't know how to apply it):
Just append it like
1 2 3unlike[1, 2, 3]so that I could easily use it in my code with the help of.split()Iterate over all 1st num and sort
If 1st num is equal to another 1st num:
Check who has a lower 2nd num and move it on top
If 2nd num is equal:
Check who has a lower 3rd num and move it on top
And so on.