sort entries in directory view

This commit is contained in:
Crispy 2023-03-14 16:19:23 +01:00
parent aecedfb4be
commit cbc924f46e

View file

@ -8,6 +8,7 @@ use crossterm::{
},
};
use std::{
cmp::Ordering,
env, fs,
io::{stdout, Write},
path::PathBuf,
@ -255,6 +256,15 @@ impl Navigator {
for file in fs::read_dir(&self.path).unwrap().flatten() {
self.files.push(file.path());
}
self.files[1..].sort_unstable_by(|path, other| {
if path.is_dir() == other.is_dir() {
path.cmp(other)
} else if path.is_dir() {
Ordering::Less
} else {
Ordering::Greater
}
});
}
fn any_unsaved(&self) -> bool {