Jun-20-2024, 01:32 PM
i am trying to sort a list of dictionaries based by a value of a specific key under the column of name values. i found two ways to do this
first i found
first i found
new_lst=sorted(lst,key=itemgetter(name))this gives me an error code of
Error:TypeError: unhashable type: 'list'
i have also triednew_lst=sorted(lst,key=lambda d: d["name"])the latter one gives me an error of
Error:TypeError: list indices must be integers or slices, not str
i have scoured the net and i cant understand why these methods dont work.... please help