On this page
locale.strxfrm
Prev: locale.strcoll | Up: locale
Rel: locale.atof, locale.atoi, locale.currency, locale.Error
Ref: docs.python.org — locale.strxfrm
Tags: #public #python3 #stdlib #locale
Import
import locale
from locale import strxfrm
Signature & Overview
locale.strxfrm(string, /)
Return a string that can be used as a key for locale-aware comparisons.
Usage
import locale
words = sorted(["b", "a", "c"], key=locale.strxfrm)
assert words == ["a", "b", "c"]
Gotchas
- Pass directly as
key=locale.strxfrmtosorted()/list.sort().
REPL Inspect
from locale import strxfrm
help(strxfrm)
Linked from
Related notes
- tuts/python3/stdlib_module/locale/strcoll Linked here; links to this page; shared tags: #locale, #stdlib
- tuts/python3/stdlib_module/locale Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/locale/atof Linked here; shared tags: #locale, #stdlib
- tuts/python3/stdlib_module/locale/atoi Linked here; shared tags: #locale, #stdlib
- tuts/python3/stdlib_module/locale/currency Linked here; shared tags: #locale, #stdlib
- tuts/python3/stdlib_module/locale/Error Linked here; shared tags: #locale, #stdlib
- tuts/python3/stdlib_module/locale/format_string shared tags: #locale, #stdlib
- tuts/python3/stdlib_module/locale/getdefaultlocale shared tags: #locale, #stdlib
- tuts/python3/stdlib_module/locale/getencoding shared tags: #locale, #stdlib
- tuts/python3/stdlib_module/locale/getlocale shared tags: #locale, #stdlib