Fix navigation sorting

This commit is contained in:
ef3d0c3e 2024-11-03 12:16:51 +01:00
parent 6d1d8269ca
commit 18d69b6d85

View file

@ -119,36 +119,25 @@ impl NavEntries {
left_title: &str, left_title: &str,
right_title: &str, right_title: &str,
) -> std::cmp::Ordering { ) -> std::cmp::Ordering {
let left_previous = entrymap.get(left_title).unwrap(); let lp = entrymap.get(left_title).unwrap();
let right_previous = entrymap.get(right_title).unwrap(); let rp = entrymap.get(right_title).unwrap();
match (left_previous, right_previous) { if lp.clone().map(|s| s.as_str() == right_title) == Some(true) {
(Some(lp), Some(rp)) => { std::cmp::Ordering::Greater
if lp.as_str() == right_title { } else if rp.clone().map(|s| s.as_str() == left_title) == Some(true) {
std::cmp::Ordering::Greater std::cmp::Ordering::Less
} else if rp.as_str() == left_title { } else if lp.is_some() && rp.is_none() {
std::cmp::Ordering::Less std::cmp::Ordering::Greater
} else if rp.as_str() == lp.as_str() { } else if rp.is_some() && lp.is_none() {
left_title.cmp(right_title) std::cmp::Ordering::Less
} else { } else if let (Some(pl), Some(pr)) = (lp, rp) {
Self::sort_entry(entrymap, lp.as_str(), rp.as_str()) if pl == pr {
} left_title.cmp(right_title)
} else {
Self::sort_entry(entrymap, pl, pr)
} }
(Some(lp), None) => { } else {
if right_title == lp.as_str() { left_title.cmp(right_title)
std::cmp::Ordering::Greater
} else {
left_title.cmp(right_title)
}
}
(None, Some(rp)) => {
if left_title == rp.as_str() {
std::cmp::Ordering::Less
} else {
left_title.cmp(right_title)
}
}
(None, None) => left_title.cmp(right_title),
} }
} }
} }