From 6589f344e431da9dff3fc075cb212c7dd1a6f937 Mon Sep 17 00:00:00 2001 From: lucaspalomodevelop Date: Sat, 7 Oct 2023 12:53:24 +0200 Subject: [PATCH] sort command-order for help command --- src/command.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/command.h b/src/command.h index 1fdc14e..77fbee2 100644 --- a/src/command.h +++ b/src/command.h @@ -44,7 +44,14 @@ public: std::string getHelpAsString() { std::string help = ""; - for (auto &commandInfo : this->commands) + + std::list sortedCommands = this->commands; + + sortedCommands.sort([](const commandInfo &a, const commandInfo &b) { + return a.name < b.name; + }); + + for (auto &commandInfo : sortedCommands) { help += commandInfo.name + " - " + commandInfo.description + "\n"; }