<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to sort list by size of group by? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-list-by-size-of-group-by/m-p/215917#M63324</link>
    <description>&lt;P&gt;I have a query of the form&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;'stats list(body) AS events BY id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which gives me for example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;id body
1 jack
2 foo
  bar
  joe
3 sun
  moon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like this to be sorted according to the size of each group, i.e., the output should be &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    id body
    2 foo
      bar
      joe
    3 sun
      moon
    1 jack
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How would I achieve this?&lt;/P&gt;</description>
    <pubDate>Wed, 09 Nov 2016 20:53:17 GMT</pubDate>
    <dc:creator>viggor</dc:creator>
    <dc:date>2016-11-09T20:53:17Z</dc:date>
    <item>
      <title>How to sort list by size of group by?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-list-by-size-of-group-by/m-p/215917#M63324</link>
      <description>&lt;P&gt;I have a query of the form&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;'stats list(body) AS events BY id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which gives me for example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;id body
1 jack
2 foo
  bar
  joe
3 sun
  moon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like this to be sorted according to the size of each group, i.e., the output should be &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    id body
    2 foo
      bar
      joe
    3 sun
      moon
    1 jack
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How would I achieve this?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 20:53:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-list-by-size-of-group-by/m-p/215917#M63324</guid>
      <dc:creator>viggor</dc:creator>
      <dc:date>2016-11-09T20:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort list by size of group by?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-list-by-size-of-group-by/m-p/215918#M63325</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | stats list(body) AS events BY id | eval t=mvcount(events) | sort -t | fields -t 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Nov 2016 20:59:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-list-by-size-of-group-by/m-p/215918#M63325</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-11-09T20:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort list by size of group by?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-list-by-size-of-group-by/m-p/215919#M63326</link>
      <description>&lt;P&gt;Nice thanks, should the last part of your query maybe be &lt;CODE&gt;sort -t | table id  events -t&lt;/CODE&gt; ?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 21:04:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-list-by-size-of-group-by/m-p/215919#M63326</guid>
      <dc:creator>viggor</dc:creator>
      <dc:date>2016-11-09T21:04:08Z</dc:date>
    </item>
  </channel>
</rss>

