From 77859cd2eefaaf474163200af0026e8edfca6b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Wed, 10 Mar 2021 23:42:53 +0100 Subject: [PATCH] fix nav sorting (sort files by their stems) also remove forgotten debug println --- src/main.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 207f0ac..3e2676d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -282,17 +282,18 @@ fn update_garden>( None }) .collect(); - files.sort(); - files.sort_by_key(|p| { - println!("{:?}", p); - match p.extension() { - None => -1, - Some(ext) => { - if ext == "md" { - 0 - } else { - 1 - } + files.sort_by(move |a, b| { + let a_sort = a.file_stem().unwrap_or_else(|| a.as_os_str()); + let b_sort = b.file_stem().unwrap_or_else(|| b.as_os_str()); + a_sort.cmp(b_sort) + }); + files.sort_by_key(|p| match p.extension() { + None => -1, + Some(ext) => { + if ext == "md" { + 0 + } else { + 1 } } });