diff --git a/src/builder/tutorial.rs b/src/builder/tutorial.rs index 7adebb8..a2d150a 100644 --- a/src/builder/tutorial.rs +++ b/src/builder/tutorial.rs @@ -190,7 +190,14 @@ impl TutorialFolder { pub fn folders_sorted(&self) -> Vec<&TutorialFolder> { let mut vec = self.folders.iter().collect::>(); - vec.sort_by_key(|t| t.0); + vec.sort_unstable_by(|a, b| { + match (a.1.metadata.clone().and_then(|x| x.order), b.1.metadata.clone().and_then(|x| x.order)) { + (Some(a), Some(b)) => a.cmp(&b), + (Some(_), None) => Ordering::Less, + (None, Some(_)) => Ordering::Greater, + (None, None) => a.0.cmp(&b.0), + } + }); vec.into_iter().map(|(_, v)| v).collect() }