I'm using Python 3.7. I have an array of JSON objects. I would like to sort the array of objects based on one of the values ("score") in each JOSN object. I'm having trouble figuring out how to write the sort function. I tried this
>>> arr = [{'score': 10, 'name': 'Bob'}, {'score': 15, 'name':'Susan'}, {'score': 1, 'name': 'Skippy'}]
>>> arr
[{'score': 10, 'name': 'Bob'}, {'score': 15, 'name': 'Susan'}, {'score': 1, 'name': 'Skippy'}]
>>> arr.sort(key=json['score'], reverse=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'json' is not defined
>>> arr.sort(key=json['score'], reverse=True)
but I can't figure out how to reference the JSON object from the "key" part of the sort function.