Fix navigation sorting
This commit is contained in:
parent
6d1d8269ca
commit
18d69b6d85
1 changed files with 17 additions and 28 deletions
|
@ -119,38 +119,27 @@ 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)) => {
|
|
||||||
if lp.as_str() == right_title {
|
|
||||||
std::cmp::Ordering::Greater
|
std::cmp::Ordering::Greater
|
||||||
} else if rp.as_str() == left_title {
|
} else if rp.clone().map(|s| s.as_str() == left_title) == Some(true) {
|
||||||
std::cmp::Ordering::Less
|
std::cmp::Ordering::Less
|
||||||
} else if rp.as_str() == lp.as_str() {
|
} else if lp.is_some() && rp.is_none() {
|
||||||
left_title.cmp(right_title)
|
|
||||||
} else {
|
|
||||||
Self::sort_entry(entrymap, lp.as_str(), rp.as_str())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(Some(lp), None) => {
|
|
||||||
if right_title == lp.as_str() {
|
|
||||||
std::cmp::Ordering::Greater
|
std::cmp::Ordering::Greater
|
||||||
} else {
|
} else if rp.is_some() && lp.is_none() {
|
||||||
left_title.cmp(right_title)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(None, Some(rp)) => {
|
|
||||||
if left_title == rp.as_str() {
|
|
||||||
std::cmp::Ordering::Less
|
std::cmp::Ordering::Less
|
||||||
|
} else if let (Some(pl), Some(pr)) = (lp, rp) {
|
||||||
|
if pl == pr {
|
||||||
|
left_title.cmp(right_title)
|
||||||
|
} else {
|
||||||
|
Self::sort_entry(entrymap, pl, pr)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
left_title.cmp(right_title)
|
left_title.cmp(right_title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(None, None) => left_title.cmp(right_title),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_navigation(
|
pub fn create_navigation(
|
||||||
|
|
Loading…
Reference in a new issue