on linux it is sorted, but not on windows. for cross-platform compatibility, might want to sort it on windows.
I would propose adding a sort::Bool=true
keyword argument to readdir
so that people can opt out of the sorting operation if they really need to. Defaulting to true seems reasonable because directories do not tend to have that many entries in them and it's easy to write code assuming that this will always be sorted on one platform and have it break on another. With the opt-out keyword, at least you know that what you're getting won't necessarily be sorted.
I will prepare a PR if no one minds.
"on linux it is sorted, but not on windows"
Yes, e.g. for ls, but besides asking for differents sorts, e.g. by time, I also see:
"-U do not sort; list entries in directory order"
In case that's the order actually stored in, and tiny bit faster, you could default to it, with sort=false?
"Huge bug uncovered ... because different operating systems sort files differently and the published scripts don鈥檛 handle it well." !!!
馃憤 That story pretty much demolished the somewhat weak (imo) arguments against doing this.
Most helpful comment
I would propose adding a
sort::Bool=true
keyword argument toreaddir
so that people can opt out of the sorting operation if they really need to. Defaulting to true seems reasonable because directories do not tend to have that many entries in them and it's easy to write code assuming that this will always be sorted on one platform and have it break on another. With the opt-out keyword, at least you know that what you're getting won't necessarily be sorted.