title: Groovy. Sort array of maps by key of a nested map within
body: <p>How do I write some groovy script to return an array of names (<code>name</code>) sorted by the <code>created_at</code> key that is nested within the <code>commit</code> key?</p>
  <p>Using <a href="https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab-ce/repository/tags" rel="nofollow noreferrer">this</a> as sample data:</p>
  <pre><code>[
  {&quot;name&quot;:&quot;v10.8.0-rc13&quot;,
  &quot;message&quot;:&quot;Version v10.8.0-rc13&quot;,
  &quot;target&quot;:&quot;171b50a40984c358a07c7e37ee95f8d788718198&quot;,
  &quot;commit&quot;:
   {
   &quot;id&quot;:&quot;1b3911c3cc8e72cc93370a90a597e2a0b944bcc2&quot;,
   &quot;short_id&quot;:&quot;1b3911c3&quot;,
   &quot;title&quot;:&quot;Update VERSION to 10.8.0-rc13&quot;,
   &quot;created_at&quot;:&quot;2018-05-18T12:43:58.000+01:00&quot;,       &lt;------ I WANT TO SORT BY THIS 
   &quot;parent_ids&quot;:[&quot;a7090d00098a4acc03cfc2b01df8019c918bd0bc&quot;],
   &quot;message&quot;:&quot;Update VERSION to 10.8.0-rc13\n&quot;,
   &quot;author_name&quot;:&quot;Filipa Lacerda&quot;,
   &quot;author_email&quot;:&quot;filipa@gitlab.com&quot;,
   &quot;authored_date&quot;:&quot;2018-05-18T12:43:58.000+01:00&quot;,
   &quot;committer_name&quot;:&quot;Filipa Lacerda&quot;,
   &quot;committer_email&quot;:&quot;filipa@gitlab.com&quot;,
   &quot;committed_date&quot;:&quot;2018-05-18T12:43:58.000+01:00&quot;
    },
  &quot;release&quot;:null
  },
  .
  .
  .
  ]
  </code></pre>
  <p>So far, I'm using something like this to get the list of unsorted names:</p>
  <pre><code>List&lt;String&gt; tags= new ArrayList&lt;String&gt;()
  
  def url=&quot;curl -X GET http://blah_blah&quot;
  def payload = url.execute().text
  def slurper = new JsonSlurper()
  def response = slurper.parseText(payload)
  
  for(item in response)
  {
     tags.add(item.name)
  }
  
  println(tags)
  </code></pre>
  <p>In this case, <code>response</code> is of type <code>java.util.ArrayList</code></p>
  <p>and <code>response[0]</code> is of type <code>groovy.json.internal.LazyMap</code></p>
  <p>All the examples I have found so far use the <code>.sort</code> or <code>.SortBy</code> methods that don't work on a <code>LazyMap</code>. <em><strong>**UPDATE**</strong> I don't think this is a true</em> statement.</p>