title: How can I sort results by aggregate in Cloudwatch Log Insights?
body: <p>I have a pretty straightforward query:</p>
  
  <pre><code>fields @timestamp, req.url, msg
  | sort @timestamp desc
  | filter msg = "request completed"
  | stats count() by req.url
  </code></pre>
  
  <p>It presents all requests served by my app aggregated by url. However, I would also like to sort the results by the value of aggregate <code>count()</code> - but both <code>| sort count desc</code> and <code>| sort "count()" desc</code> don't work. How can I achieve that?</p>