From 466d0889210b1308b7837ac5c020a80589f1a04d Mon Sep 17 00:00:00 2001 From: lucaspalomodevelop Date: Sat, 7 Oct 2023 15:13:26 +0200 Subject: [PATCH] reslove sortedHelp output .-. --- src/command.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/command.hpp b/src/command.hpp index c3f0d2f..ca7b367 100644 --- a/src/command.hpp +++ b/src/command.hpp @@ -45,10 +45,17 @@ 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"; } + return help; }