I wonder how such a list should sort the following list
lst = ['abb', 'ABB', 'aBa', 'AbA']
The proposed solution gives the following result
>>> sorted(lst, key=lambda L: (L.lower(), L)) ['AbA', 'aBa', 'ABB', 'abb']
I can offer a more complex solution with different results
>>> sorted(lst, key=lambda a: sum(([a[:i].lower(), a[:i]] for i in range(1, len(a)+1)),[])) ['ABB', 'AbA', 'aBa', 'abb']
source share