title: How to sort JSON objects of arrays in python?
body: <p>I want to sort a JSON object of arrays on the basis of the key &quot;score&quot;. Here's a sample data:</p>
  <pre><code>[
      {
          &quot;name&quot;: &quot;Hilary Carr&quot;,
          &quot;submissions&quot;: [
              {
                  &quot;name&quot;: &quot;Laudantium deleniti beatae fuga.&quot;,
                  &quot;date&quot;: &quot;05/12/2021&quot;,
                  &quot;score&quot;: 37
              }
          ]
      },
  {
          &quot;name&quot;: &quot;Frederick Williamson&quot;,
          &quot;submissions&quot;: [
              {
                  &quot;name&quot;: &quot;Expedita architecto voluptas autem veniam.&quot;,
                  &quot;date&quot;: &quot;03/05/2009&quot;,
                  &quot;score&quot;: 47
              },
              {
                  &quot;name&quot;: &quot;Animi facere excepturi.&quot;,
                  &quot;date&quot;: &quot;01/02/2021&quot;,
                  &quot;score&quot;: 100
              }
          ]
      }
  ]
  </code></pre>
  <p>Sample output:</p>
  <pre><code>[
      {
          &quot;name&quot;: &quot;Hilary Carr&quot;,
          &quot;submissions&quot;: [
              {
                  &quot;name&quot;: &quot;Laudantium deleniti beatae fuga.&quot;,
                  &quot;date&quot;: &quot;05/12/2021&quot;,
                  &quot;score&quot;: 37
              }
          ]
      },
  {
          &quot;name&quot;: &quot;Frederick Williamson&quot;,
          &quot;submissions&quot;: [
              {
                  &quot;name&quot;: &quot;Animi facere excepturi.&quot;,
                  &quot;date&quot;: &quot;01/02/2021&quot;,
                  &quot;score&quot;: 100
              },
              {
                  &quot;name&quot;: &quot;Expedita architecto voluptas autem veniam.&quot;,
                  &quot;date&quot;: &quot;03/05/2009&quot;,
                  &quot;score&quot;: 47
              }
          ]
      }
  ]
  </code></pre>
  <p>I tried the solution given in this question <a href="https://stackoverflow.com/questions/43255909/sort-a-json-using-python">Sort a JSON using Python</a>, but my JSON data is mutilated by this. Here's what I tried:</p>
  <pre><code>for i in range(len(inputData)):
      sample_data_sort = dict(inputData)
      sample_data_sort = sorted(inputData[i]['submissions'], key=lambda x : x['score'], reverse=True)
      print(sample_data_sort)
  </code></pre>
  <p>Output that I get:</p>
  <pre><code>[
    {
     &quot;name&quot;: &quot;Laudantium deleniti beatae fuga.&quot;,
     &quot;date&quot;: &quot;05/12/2021&quot;,
     &quot;score&quot;: 37
     }
  ],
  [
   {
   &quot;name&quot;: &quot;Animi facere excepturi.&quot;,
   &quot;date&quot;: &quot;01/02/2021&quot;,
   &quot;score&quot;: 100
   },
   {
    &quot;name&quot;: &quot;Expedita architecto voluptas autem veniam.&quot;,
    &quot;date&quot;: &quot;03/05/2009&quot;,
    &quot;score&quot;: 47
   }
  ]
  </code></pre>
  <p>As you can see, I get the mutilated JSON back. Can you please give some tips to rectify this problem, so that the output that I get is similar to the input?</p>