From 5069f464cc8456c0000e46be27992b216b2db299 Mon Sep 17 00:00:00 2001 From: Kreusada <67752638+Kreusada@users.noreply.github.com> Date: Thu, 14 Sep 2023 00:35:59 +0100 Subject: [PATCH] Sort cogs alphabetically inside `[p]cog list` (#6215) --- redbot/cogs/downloader/downloader.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 0cd7e63ed1f..29a9d126e87 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1330,11 +1330,12 @@ async def _cog_list(self, ctx: commands.Context, repo: Repo) -> None: - `` The repo to list cogs from. """ + sort_function = lambda x: x.name.lower() all_installed_cogs = await self.installed_cogs() installed_cogs_in_repo = [cog for cog in all_installed_cogs if cog.repo_name == repo.name] installed_str = "\n".join( "- {}{}".format(i.name, ": {}".format(i.short) if i.short else "") - for i in installed_cogs_in_repo + for i in sorted(installed_cogs_in_repo, key=sort_function) ) if len(installed_cogs_in_repo) > 1: @@ -1347,7 +1348,7 @@ async def _cog_list(self, ctx: commands.Context, repo: Repo) -> None: ] available_str = "\n".join( "+ {}{}".format(cog.name, ": {}".format(cog.short) if cog.short else "") - for cog in available_cogs + for cog in sorted(available_cogs, key=sort_function) ) if not available_str: