Skip to content

Commit 625ff84

Browse files
committed
Use sort_by_key
1 parent 4807a8b commit 625ff84

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ fn build_attribute_distributions(
590590
.into_iter()
591591
.map(|(key, counter)| {
592592
let mut distributions: Vec<(AttributeType, usize)> = counter.into_iter().collect();
593-
distributions.sort_by(|a, b| b.1.cmp(&a.1)); // sort by count desc
593+
distributions.sort_by_key(|d| std::cmp::Reverse(d.1)); // sort by count desc
594594
AttributeDistribution {
595595
attribute_name: key.clone(),
596596
distributions,

src/help.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub fn prune_spans_to_fit_width(
112112
let mut spans_with_priority_with_index: Vec<(usize, &SpansWithPriority)> =
113113
spans_with_priorities.iter().enumerate().collect();
114114

115-
spans_with_priority_with_index.sort_by(|(_, sp1), (_, sp2)| sp2.priority.cmp(&sp1.priority));
115+
spans_with_priority_with_index.sort_by_key(|(_, sp)| std::cmp::Reverse(sp.priority));
116116

117117
let mut prune: Vec<usize> = Vec::new();
118118
for (i, sp) in &spans_with_priority_with_index {

0 commit comments

Comments
 (0)