Hi could anyone explain to me how to sort the folder names in order of creation?
list1=["New folder", "New folder 1", "New folder 10", "New folder 2"]
sorted(list1)
print("output ",list1)
The outputs is currently:
>> ["New folder", "New folder 1", "New folder 10", "New folder 2"]
I would like it show:
["New folder", "New folder 1", "New folder 2", "New folder 10"]
The reason I need this order is because I am opening directories via these folder names in order.
Below is the code I am using to grab these folder names maybe there is a way to sort them in the required order as I make the array?
itrprev = iter(os.walk(previousdir))
root, dirs, files = next(itrprev)
for next_root, next_dirs, next_files in itrprev: # get second element onwards
print("Next dir full path: : ", next_root)
singlefoldername = os.path.split(next_root)
fullfoldername = os.path.abspath(next_root)