1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from functools import cmp_to_key
>>> import locale
>>>
>>> country_list = ['France', 'Royaume-Uni', 'Géorgie', 'Guinée', 'Indonésie',
'Île de Man', 'Islande', 'Japon', 'Kenya', 'Corée du Sud', 'Kosovo', 'Lesotho',
'Luxembourg', 'Nigéria', 'Suriname', 'Seychelles', 'Îles Turques-et-Caïques',
'Tchad', 'Tuvalu', 'Uganda', 'Uruguay', 'Saint-Vincent-et-les-Grenadines',
'Venezuela', 'Andorre', 'Arménie', 'Antigua-et-Barbuda', 'Azerbaïdjan',
'Burundi', 'Burkina Faso', 'Bangladesh']
>>>
>>> country_list = sorted(country_list, key=cmp_to_key(locale.strcoll))
>>> print(country_list)
['Andorre', 'Antigua-et-Barbuda', 'Arménie', 'Azerbaïdjan', 'Bangladesh',
'Burkina Faso', 'Burundi', 'Corée du Sud', 'France', 'Guinée', 'Géorgie',
'Indonésie', 'Islande', 'Japon', 'Kenya', 'Kosovo', 'Lesotho', 'Luxembourg',
'Nigéria', 'Royaume-Uni', 'Saint-Vincent-et-les-Grenadines',
'Seychelles', 'Suriname', 'Tchad', 'Tuvalu', 'Uganda', 'Uruguay',
'Venezuela', 'Île de Man', 'Îles Turques-et-Caïques']
>>> |