title: Using jq group_by and count to sort JSON output from curl into sorted and counted list
body: <p>Can anyone help me to understand and assist with a jq script please (only using jq)? Can anyone help me to write a script to take the output of:</p>
  <pre><code>`curl --silent &quot;https://api.surfshark.com/v3/server/clusters&quot; | jq` 
  </code></pre>
  <p>and list the number of servers in each <strong>countryCode</strong> and the <strong>min</strong> and <strong>max</strong> loadings on those servers, <strong>sorted by countryCode</strong>?</p>
  <pre><code>.countryCode 'count of number of servers' 'lowest .load' 'highest .load'
  AU    5    13%       30%
  UK   10    35%       88%
  US   25    12%       50%
  </code></pre>
  <p>etc....</p>
  <p>I believe the use of group_by, or a combination of that and map, set path, get path and count may work, but I'm hoping someone with higher skills can help me.</p>
  <p>Each json entry looks like this:</p>
  <pre><code>
  [
    {
      &quot;country&quot;: &quot;Albania&quot;,
      &quot;**countryCode**&quot;: &quot;AL&quot;,
      &quot;region&quot;: &quot;Europe&quot;,
      &quot;regionCode&quot;: &quot;EU&quot;,
      &quot;**load**&quot;: 12,
      &quot;id&quot;: &quot;4c333aa2-d08b-4d11-9073-61c351ce1c1e&quot;,
      &quot;coordinates&quot;: {
        &quot;longitude&quot;: 19.8188889,
        &quot;latitude&quot;: 41.3275
      },
      &quot;info&quot;: [
        {
          &quot;id&quot;: &quot;55994450-0c87-4df3-b585-3836c67a863d&quot;,
          &quot;entry&quot;: {
            &quot;value&quot;: &quot;U2FsdGVkX1/VX5IKc3H3ruClgbw7JgnqW7Eacumx8aM=&quot;
          }
        }
      ],
      &quot;type&quot;: &quot;generic&quot;,
      &quot;location&quot;: &quot;Tirana&quot;,
      &quot;**connectionName**&quot;: &quot;al-tia.prod.surfshark.com&quot;,
  </code></pre>
  <p>Extract from another post referencing some of the possible commands</p>
  <pre><code>'map(.Properties.ItmId)
  | reduce .[] as $i (
      {}; setpath([$i]; getpath([$i]) + 1)
    )
  | to_entries | .[] | { &quot;ItemId&quot;: .key, &quot;Count&quot;: .value }'
  </code></pre>