From 147bfefd7e575c6450f8380dc8d301b0aef2fd2a Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sat, 11 Jan 2020 20:59:55 +1300 Subject: [PATCH] Sort ls case-insensitively by default (#1192) --- src/shell/filesystem_shell.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/shell/filesystem_shell.rs b/src/shell/filesystem_shell.rs index 5750d7b123..d30bcd206a 100644 --- a/src/shell/filesystem_shell.rs +++ b/src/shell/filesystem_shell.rs @@ -122,6 +122,17 @@ impl Shell for FilesystemShell { } Ok(o) => o, }; + let mut entries = entries.collect::>>(); + entries.sort_by(|x, y| match (x, y) { + (Ok(entry1), Ok(entry2)) => entry1 + .path() + .to_string_lossy() + .to_lowercase() + .cmp(&entry2.path().to_string_lossy().to_lowercase()), + (Err(_), Ok(_)) => std::cmp::Ordering::Greater, + (Ok(_), Err(_)) => std::cmp::Ordering::Greater, + _ => std::cmp::Ordering::Equal, + }); let stream = async_stream! { for entry in entries { if ctrl_c.load(Ordering::SeqCst) {