From 7f971703e23760291d0bfbf423f28c8533692f2f Mon Sep 17 00:00:00 2001 From: projectmoon Date: Thu, 22 Oct 2020 21:24:24 +0000 Subject: [PATCH] Sort variable list when showing all variables. Fixes #28 --- src/commands.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index fc34bf1..03fb430 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -121,11 +121,15 @@ impl Command for GetAllVariablesCommand { async fn execute(&self, ctx: &Context) -> Execution { let value = match ctx.db.get_user_variables(&ctx.room_id, &ctx.username).await { - Ok(variables) => variables - .into_iter() - .map(|(name, value)| format!(" - {} = {}", name, value)) - .collect::>() - .join("\n"), + Ok(variables) => { + let mut variable_list = variables + .into_iter() + .map(|(name, value)| format!(" - {} = {}", name, value)) + .collect::>(); + + variable_list.sort(); + variable_list.join("\n") + } Err(e) => format!("error getting variables: {}", e), };