Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sort output of readdir #24626

Closed
bjarthur opened this issue Nov 16, 2017 · 5 comments
Closed

sort output of readdir #24626

bjarthur opened this issue Nov 16, 2017 · 5 comments
Labels
domain:filesystem Underlying file system and functions that use it

Comments

@bjarthur
Copy link
Contributor

on linux it is sorted, but not on windows. for cross-platform compatibility, might want to sort it on windows.

@StefanKarpinski
Copy link
Sponsor Member

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.

@StefanKarpinski StefanKarpinski added good first issue Indicates a good issue for first-time contributors to Julia status:help wanted Indicates that a maintainer wants help on an issue or pull request domain:filesystem Underlying file system and functions that use it labels Nov 16, 2017
@carstenbauer
Copy link
Member

I will prepare a PR if no one minds.

@PallHaraldsson
Copy link
Contributor

"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?

@bjarthur
Copy link
Contributor Author

"Huge bug uncovered ... because different operating systems sort files differently and the published scripts don’t handle it well." !!!

https://arstechnica.com/information-technology/2019/10/chemists-discover-cross-platform-python-scripts-not-so-cross-platform/

@StefanKarpinski
Copy link
Sponsor Member

👍 That story pretty much demolished the somewhat weak (imo) arguments against doing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:filesystem Underlying file system and functions that use it
Projects
None yet
Development

No branches or pull requests

5 participants