diff --git a/lightningd/jsonrpc.c b/lightningd/jsonrpc.c index 5eecd3b1b..6932d2d3f 100644 --- a/lightningd/jsonrpc.c +++ b/lightningd/jsonrpc.c @@ -13,11 +13,13 @@ * that point, the `json_connection` becomes the owner (or it's simply freed). */ /* eg: { "jsonrpc":"2.0", "method" : "dev-echo", "params" : [ "hello", "Arabella!" ], "id" : "1" } */ +#include "ccan/config.h" #include #include #include #include #include +#include #include #include #include @@ -346,6 +348,12 @@ static const struct json_command *find_command(struct json_command **commands, return NULL; } +static int compare_commands_name(struct json_command *const *a, + struct json_command *const *b, void *unused) +{ + return strcmp((*a)->name, (*b)->name); +} + static struct command_result *json_help(struct command *cmd, const char *buffer, const jsmntok_t *obj UNNEEDED, @@ -372,6 +380,8 @@ static struct command_result *json_help(struct command *cmd, } else one_cmd = NULL; + asort(commands, tal_count(commands), compare_commands_name, NULL); + response = json_stream_success(cmd); json_object_start(response, NULL); json_array_start(response, "help");