python listing dirs in a different order based upon platform
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Peaceful Mind
--
Chapters
00:00 Python Listing Dirs In A Different Order Based Upon Platform
01:36 Accepted Answer Score 13
02:05 Answer 2 Score 14
02:10 Thank you
--
Full question
https://stackoverflow.com/questions/5667...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #oswalk
#avk47
    Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Peaceful Mind
--
Chapters
00:00 Python Listing Dirs In A Different Order Based Upon Platform
01:36 Accepted Answer Score 13
02:05 Answer 2 Score 14
02:10 Thank you
--
Full question
https://stackoverflow.com/questions/5667...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #oswalk
#avk47
ANSWER 1
Score 14
for path, dirs, files in os.walk('d:\ssptemp'):
    # sort dirs and files
    dirs.sort()
    files.sort()
    print "parsing dir(s)"
    # ...
ACCEPTED ANSWER
Score 13
The order of directories within os.walk is not necessarily alphabetical (I think it's actually dependent upon how they're stored within the dirent on the filesystem).  It will likely be stable on the same exact directory (on the same filesystem) if you don't change the directory contents (ie, repeated calls will return the same order), but the order is not necessarily alphabetical.
If you want to have an ordered list of filenames you will have to build the list and then sort it yourself.