Skip to content

Commit ff1c12a

Browse files
authored
Correct Glossary key function example to use str.casefold instead of str.lower
The glossary currently states: “the str.lower() method can serve as a key function for case-insensitive sorts.” I believe this should be updated to use str.casefold() instead. str.casefold() is recommended for case-insensitive matching in Unicode, and it provides more accurate behavior across languages than str.lower(). This also aligns with the "Sorting Techniques" section of the docs, which uses str.casefold() as the key function for case-insensitive sorting.
1 parent bedaea0 commit ff1c12a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Doc/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ Glossary
813813
:func:`itertools.groupby`.
814814

815815
There are several ways to create a key function. For example. the
816-
:meth:`str.lower` method can serve as a key function for case insensitive
816+
:meth:`str.casefold` method can serve as a key function for case insensitive
817817
sorts. Alternatively, a key function can be built from a
818818
:keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also,
819819
:func:`operator.attrgetter`, :func:`operator.itemgetter`, and

0 commit comments

Comments
 (0)