|
1 | | -use std::{cmp::Ordering, collections::HashMap}; |
| 1 | +use std::{ |
| 2 | + cmp::{Ordering, Reverse}, |
| 3 | + collections::HashMap, |
| 4 | +}; |
2 | 5 |
|
3 | 6 | use bathbot_macros::command; |
4 | 7 | use bathbot_util::{constants::GENERAL_ISSUE, matcher}; |
@@ -154,19 +157,13 @@ async fn top(orig: CommandOrigin<'_>, args: RelaxTop<'_>) -> Result<()> { |
154 | 157 | .beats_per_minute |
155 | 158 | .total_cmp(&lhs.beatmap.beats_per_minute) |
156 | 159 | }), |
157 | | - RelaxTopOrder::Combo => scores.sort_unstable_by(|lhs, rhs| rhs.combo.cmp(&lhs.combo)), |
158 | | - RelaxTopOrder::Date => scores.sort_unstable_by(|lhs, rhs| rhs.date.cmp(&lhs.date)), |
159 | | - RelaxTopOrder::Misses => { |
160 | | - scores.sort_unstable_by(|lhs, rhs| rhs.count_miss.cmp(&lhs.count_miss)) |
161 | | - } |
162 | | - RelaxTopOrder::ModsCount => { |
163 | | - scores.sort_unstable_by(|lhs, rhs| rhs.mods.len().cmp(&lhs.mods.len())) |
164 | | - } |
| 160 | + RelaxTopOrder::Combo => scores.sort_unstable_by_key(|a| Reverse(a.combo)), |
| 161 | + RelaxTopOrder::Date => scores.sort_unstable_by_key(|a| Reverse(a.date)), |
| 162 | + RelaxTopOrder::Misses => scores.sort_unstable_by_key(|a| Reverse(a.count_miss)), |
| 163 | + RelaxTopOrder::ModsCount => scores.sort_unstable_by_key(|a| Reverse(a.mods.len())), |
165 | 164 | RelaxTopOrder::Pp => scores |
166 | 165 | .sort_unstable_by(|lhs, rhs| rhs.pp.partial_cmp(&lhs.pp).unwrap_or(Ordering::Equal)), |
167 | | - RelaxTopOrder::Score => { |
168 | | - scores.sort_unstable_by(|lhs, rhs| rhs.total_score.cmp(&lhs.total_score)) |
169 | | - } |
| 166 | + RelaxTopOrder::Score => scores.sort_unstable_by_key(|a| Reverse(a.total_score)), |
170 | 167 | } |
171 | 168 |
|
172 | 169 | let pagination = RelaxTopPagination::builder() |
|
0 commit comments