From 9ddb532e5140fc7971ee9f1290f9861c9f60a599 Mon Sep 17 00:00:00 2001 From: Damien Picard Date: Mon, 22 Jun 2026 16:09:16 +0200 Subject: [PATCH] Credits Script: Improve author name collation by decomposing them Some authors have names containing non-English letters. Using the default sort, those names are written at the end of the list. This commit uses `unicodedata.normalize('NFD', ...)` during sorting. This outputs the decomposed unicode variant of a string, such that diacritized letters are found after their undiacritized version instead of at the very bottom. This does not solve collation for names written in a non-latin alphabet, which would probably require external libraries. Ref !160527 --- tools/utils/credits_git_gen.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/utils/credits_git_gen.py b/tools/utils/credits_git_gen.py index 8270210c917..1aeb4ce1e33 100755 --- a/tools/utils/credits_git_gen.py +++ b/tools/utils/credits_git_gen.py @@ -215,14 +215,21 @@ class Credits: use_email: bool = False, ) -> None: commit_word = "commit", "commits" + from unicodedata import normalize + # Normalize using decomposed strings for sorting. + # That makes letters with diacritics grouped with the undiacritized variant. + # Collation is not perfect, but better than having non-English letters at the very bottom of the list. if sort == "commit": sorted_authors = dict(sorted( self.users.items(), - key=lambda item: (item[1].commit_total, item[0]), + key=lambda item: (item[1].commit_total, normalize('NFD', item[0])), )) else: - sorted_authors = dict(sorted(self.users.items())) + sorted_authors = dict(sorted( + self.users.items(), + key=lambda item: (normalize('NFD', item[0]), item[1].commit_total), + )) fh.write("

Individual Contributors

\n\n") for author, cu in sorted_authors.items():