core: sort votes

This commit is contained in:
Natsu Kagami 2020-09-14 23:39:08 -04:00
parent e46cce3cb6
commit 2ce83a86dd
No known key found for this signature in database
GPG key ID: F17543D4B9424B94

View file

@ -152,12 +152,14 @@ pub async fn vote(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
// Handle choices
let choice_map = choices.into_iter().collect::<Map<_, _>>();
let result: Vec<(String, Vec<UserId>)> = user_reactions
let mut result: Vec<(String, Vec<UserId>)> = user_reactions
.into_iter()
.filter(|(_, users)| !users.is_empty())
.map(|(emote, users)| (emote, users.into_iter().collect()))
.collect();
result.sort_unstable_by(|(_, v), (_, w)| w.len().cmp(&v.len()));
if result.len() == 0 {
msg.reply(
&ctx,