File Sorting in Python
I want to get sorted file array with python.
I have a array like following
When I use subDir = os.listdir(dirname) , it didn’t sort.
It will return like following order
- Testing 2.txt
- Testing 20.txt
- Testing 3.txt
- Testing 30.txt
We need to use sorted function to sort and we need to tell between Testing and .txt is a integer value.
Here is my code