I have a 2D List like this:
mylist = [[1, "Banana", "description"],[2, "Peach", "description"],[1,"apple", "description"],[2, "orange", "description"]]
I want to sort the list first by the numbers and then by the "name" of the object. But when I sort it with sorted(mylist)
I get following output:
mylist=[[1, 'Banana', 'description'], [1, 'apple', 'description'], [2, 'Peach', 'description'], [2, 'orange', 'description']]
Instead, I want a case insensitive sort by the name:
mylist = [[1, 'apple', 'description'], [1, 'Banana', 'description'], [2, 'orange', 'description'], [2, 'Peach', 'description']]
I tried the key key=str.casefold
but that doesn't work, as I get following error message:
TypeError: descriptor 'casefold' for 'str' objects doesn't apply to a 'list' object