Sep-22-2022, 11:23 PM
(Sep-22-2022, 09:21 AM)perfringo Wrote: If you adjust your keyfunc a little bit then you can achieve desired result.
Depending how agressive you would like to be in lowering you can use str.casefold or str.lower.
...and don't uselist
as a name.
>>> data = [['pencil', 'writing implement'], ['asteroid', 'space body'], ['Arctic', 'northern pole']] >>> sorted(data, key=lambda pair: pair[0].casefold()) [['Arctic', 'northern pole'], ['asteroid', 'space body'], ['pencil', 'writing implement']]