Bring back the reverse flag

Following the large refactor on the previous commit, this commit fixes
the reverse functionality.

Depth detection moved into the tree building instead of being calculated
when drawing the tree to screen
This commit is contained in:
andy.boot
2019-10-06 21:59:17 +01:00
parent db6c8a019d
commit 4cffc4370b
3 changed files with 42 additions and 52 deletions
-9
View File
@@ -122,15 +122,6 @@ pub fn sort_by_size_first_name_second(a: &(String, u64), b: &(String, u64)) -> O
}
}
pub fn compare_tuple_smallest_first(a: &(String, u64), b: &(String, u64)) -> Ordering {
let result = a.1.cmp(&b.1);
if result == Ordering::Equal {
b.0.cmp(&a.0)
} else {
result
}
}
pub fn sort(data: HashMap<String, u64>) -> Vec<(String, u64)> {
let mut new_l: Vec<(String, u64)> = data.iter().map(|(a, b)| (a.clone(), *b)).collect();
new_l.sort_by(|a, b| sort_by_size_first_name_second(&a, &b));