title: How to find which item in a JSON list has the greatest value for a given attribute in Python?
body: <p>I'm using JSON data from the <a href="http://worldcup.sfg.io/" rel="nofollow noreferrer">SFG WorldCup API</a>.</p>
  
  <p>What I need to do is to find the most recent goal scored by a given team in a given match. To do that, I need to sort by the value of the <code>attribute</code> key in each element of the array that is the attribute of the <code>away_team_events</code> attribute. </p>
  
  <p>Let me illustrate. </p>
  
  <p>Here's sample JSON for France from the ongoing (at the time of writing) France v Switzerland.</p>
  
  <pre><code>"away_team_events": [
              {
                  "id": 276, 
                  "type_of_event": "goal", 
                  "player": "Giroud", 
                  "time": "17"
              }, 
              {
                  "id": 277, 
                  "type_of_event": "goal", 
                  "player": "Matuidi", 
                  "time": "18"
              }, 
              {
                  "id": 278, 
                  "type_of_event": "penalty-wrong", 
                  "player": "Benzema", 
                  "time": "32"
              }, 
              {
                  "id": 279, 
                  "type_of_event": "goal", 
                  "player": "Valbuena", 
                  "time": "40"
              }, 
              {
                  "id": 281, 
                  "type_of_event": "substitution-in", 
                  "player": "Pogba", 
                  "time": "63"
              }, 
              {
                  "id": 282, 
                  "type_of_event": "substitution-in", 
                  "player": "Koscielny", 
                  "time": "66"
              }, 
              {
                  "id": 283, 
                  "type_of_event": "goal", 
                  "player": "Benzema", 
                  "time": "67"
              }
          ]
  </code></pre>
  
  <p>So what I need to do here is find which "id" attribute is greatest, because that will be the latest goal. </p>
  
  <p>How do I sort by a specific attribute like this?</p>
  
  <p>I've seen <a href="https://stackoverflow.com/questions/13438574/sorting-json-data-by-keys-value">this question</a>, but I can't really make sense of the answers.</p>
  
  <p>EDIT: rephrase, sorry for the confusion. </p>
  
  <p>I don't need to necessarily rearrange them, but how do I identify which item in the list has the greatest id, and use that?</p>