diff options
Diffstat (limited to 'sphinx/environment/adapters/indexentries.py')
-rw-r--r-- | sphinx/environment/adapters/indexentries.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/sphinx/environment/adapters/indexentries.py b/sphinx/environment/adapters/indexentries.py index 5af213932..b13ac97c3 100644 --- a/sphinx/environment/adapters/indexentries.py +++ b/sphinx/environment/adapters/indexentries.py @@ -98,9 +98,8 @@ class IndexEntries: for subentry in indexentry[1].values(): subentry[0].sort(key=keyfunc0) # type: ignore - # sort the index entries; put all symbols at the front, even those - # following the letters in ASCII, this is where the chr(127) comes from - def keyfunc(entry: Tuple[str, List]) -> Tuple[str, str]: + # sort the index entries + def keyfunc(entry: Tuple[str, List]) -> Tuple[Tuple[int, str], str]: key, (void, void, category_key) = entry if category_key: # using specified category key to sort @@ -108,11 +107,16 @@ class IndexEntries: lckey = unicodedata.normalize('NFD', key.lower()) if lckey.startswith('\N{RIGHT-TO-LEFT MARK}'): lckey = lckey[1:] + if lckey[0:1].isalpha() or lckey.startswith('_'): - lckey = chr(127) + lckey + # put non-symbol characters at the folloing group (1) + sortkey = (1, lckey) + else: + # put symbols at the front of the index (0) + sortkey = (0, lckey) # ensure a determinstic order *within* letters by also sorting on # the entry itself - return (lckey, entry[0]) + return (sortkey, entry[0]) newlist = sorted(new.items(), key=keyfunc) if group_entries: |