diff --git a/src/main.rs b/src/main.rs index 76a7063..58e0e0f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 {