Tools: Make git credits stable when sorted by commits

Only sorting by the number of commits was unstable
when authors had the same number of commits.

Make the output stable by including the name in the sort "key".

Ref !149460
This commit is contained in:
Damien Picard 2025-11-07 03:21:36 +00:00 • committed by Campbell Barton
parent 3b83d75c4e
commit 2c9fd6752e

View file

@ -216,9 +216,11 @@ class Credits:
) -> None:
commit_word = "commit", "commits"
sorted_authors = {}
if sort == "commit":
sorted_authors = dict(sorted(self.users.items(), key=lambda item: item[1].commit_total))
sorted_authors = dict(sorted(
self.users.items(),
key=lambda item: (item[1].commit_total, item[0]),
))
else:
sorted_authors = dict(sorted(self.users.items()))