Sorting numbers in each row of a table – Python code

Reading – sorting – writing to a file (Python code)

Details:

Name: SortByRow.py (Python 3.10.0)
Description: The code will open a text file called “infile.txt” and read the content of the file, which is a table of numbers. Next, each row of this table is sorted in ascending order. The new table is then written to a new text file called “outfile.txt”.

Content of input file “infile.txt”

3	38	18	41	39	1
11	32	16	41	21	39
26	27	41	1	10	24
1	32	36	42	2	8
16	26	14	5	17	33
38	17	23	29	30	32
3	24	8	23	35	19
11	22	29	18	19	36
19	24	28	1	31	39
3	29	38	32	30	31
21	39	41	26	16	9
1	22	42	24	32	39

Content of output file “outfile.txt”

1, 3, 18, 38, 39, 41
11, 16, 21, 32, 39, 41
1, 10, 24, 26, 27, 41
1, 2, 8, 32, 36, 42
5, 14, 16, 17, 26, 33
17, 23, 29, 30, 32, 38
3, 8, 19, 23, 24, 35
11, 18, 19, 22, 29, 36
1, 19, 24, 28, 31, 39
3, 29, 30, 31, 32, 38
9, 16, 21, 26, 39, 41
1, 22, 24, 32, 39, 42