title: In Python, how do I sort an array of JSON objects by a value in each object?
body: <p>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</p>
  
  <pre><code>&gt;&gt;&gt; arr = [{'score': 10, 'name': 'Bob'}, {'score': 15, 'name':'Susan'}, {'score': 1, 'name': 'Skippy'}]
  &gt;&gt;&gt; arr
  [{'score': 10, 'name': 'Bob'}, {'score': 15, 'name': 'Susan'}, {'score': 1, 'name': 'Skippy'}]
  &gt;&gt;&gt; arr.sort(key=json['score'], reverse=True)
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  NameError: name 'json' is not defined
  &gt;&gt;&gt; arr.sort(key=json['score'], reverse=True)
  </code></pre>
  
  <p>but I can't figure out how to reference the JSON object from the "key" part of the sort function.</p>