Full error: 'str' object has no attribute 'match_key'
I am trying to sort a dictionary by the values of one of the keys in the objects but I am running into errors whem doing so. What is the best way to do this kind of sort?
Code:
#part of loop
x = {
'id': f'{item.id}',
'post': item,
'match_key': match_percentage
}
temp_dict.update(x)
sorted_dict = sorted(temp_dict, key=operator.attrgetter('match_key'))