example-code-2e/04-text-byte/locale_sort.py

7 lines
225 B
Python
Raw Normal View History

2020-02-19 04:10:33 +01:00
import locale
my_locale = locale.setlocale(locale.LC_COLLATE, 'pt_BR.UTF-8')
print(my_locale)
fruits = ['caju', 'atemoia', 'cajá', 'açaí', 'acerola']
sorted_fruits = sorted(fruits, key=locale.strxfrm)
print(sorted_fruits)