Skip to content

Commit

Permalink
Sort cogs alphabetically inside [p]cog list (Cog-Creators#6215)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreusada authored and Dav-Git committed Sep 8, 2024
1 parent 747f3a8 commit 3fcc373
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions redbot/cogs/downloader/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1330,11 +1330,12 @@ async def _cog_list(self, ctx: commands.Context, repo: Repo) -> None:
- `<repo>` 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:
Expand All @@ -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:
Expand Down

0 comments on commit 3fcc373

Please sign in to comment.