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_by_file_name doesn't appear to be working #182

Open
ShayBox opened this issue Jun 1, 2023 · 2 comments
Open

sort_by_file_name doesn't appear to be working #182

ShayBox opened this issue Jun 1, 2023 · 2 comments

Comments

@ShayBox
Copy link

ShayBox commented Jun 1, 2023

let paths = WalkDir::new(current_dir)
        .sort_by_file_name()
        .into_iter()
        .filter_map(Result::ok)
        .map(DirEntry::into_path)
        .collect::<Vec<_>>();

This leads to the outcome being random every time the program is run

EDIT: I'm on Windows 11 22H2 (22621.1778) using the latest stable Rust and walkdir

@BurntSushi
Copy link
Owner

Can you provide a full reproduction? Otherwise this might be something you'll have to debug on your own.

@keyle
Copy link

keyle commented Jun 1, 2023

@ShayBox it might be because you're thinking that it sorts by file name, while in fact, it sorts by sub-folder first (by full path).

This got me confused as well at first, and ended up here, then I realised that even though it says by_file_name, it's really by_path_alphabetical.

HTH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants