mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-19 16:58:55 +00:00
core: sort votes
This commit is contained in:
parent
e46cce3cb6
commit
2ce83a86dd
1 changed files with 3 additions and 1 deletions
|
@ -152,12 +152,14 @@ pub async fn vote(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
|
||||||
|
|
||||||
// Handle choices
|
// Handle choices
|
||||||
let choice_map = choices.into_iter().collect::<Map<_, _>>();
|
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()
|
.into_iter()
|
||||||
.filter(|(_, users)| !users.is_empty())
|
.filter(|(_, users)| !users.is_empty())
|
||||||
.map(|(emote, users)| (emote, users.into_iter().collect()))
|
.map(|(emote, users)| (emote, users.into_iter().collect()))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
result.sort_unstable_by(|(_, v), (_, w)| w.len().cmp(&v.len()));
|
||||||
|
|
||||||
if result.len() == 0 {
|
if result.len() == 0 {
|
||||||
msg.reply(
|
msg.reply(
|
||||||
&ctx,
|
&ctx,
|
||||||
|
|
Loading…
Add table
Reference in a new issue