I have a directory containing a lot of textfiles named in a specific order:
0.txt
1.txt
2.txt
....
100.txt
101.txt
.....
40000.txt
When im trying to retrieve a sorted list of all the files im using:
for file in sorted(os.listdir(filepath)):
print(file)
and the result im getting is:
0.txt
1.txt
10.txt
100.txt
1000.txt
10000.txt
10001.txt
10002.txt
10003.txt
10004.txt
.....
Which is not how i want it, i want it in normal ascending order:
0.txt
1.txt
2.txt
3.txt
4.txt
...
Does anyone know how to do this?