<?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 Sort Search Command Question in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sort-Search-Command-Question/m-p/55935#M13665</link>
    <description>&lt;P&gt;Hey,&lt;/P&gt;

&lt;P&gt;In Splunk, you can sort your search results by field using the sort command.&lt;/P&gt;

&lt;P&gt;Is it possible to sort search results by row?&lt;/P&gt;

&lt;P&gt;E.g. If I have a search that produces the following table:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Day         Total&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;1 Monday         93&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;2 Tuedsay       124&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;3 Thursday      356&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;4 Weekend      1022&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;5 Wednesday     248&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;and what I really want instead is this table below (showing the days in order):&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Day         Total&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;1 Monday         93&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;2 Tuedsay       124&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;3 Wednesday     248&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;4 Thursday      356&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;5 Weekend      1022&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;How would I be able to do this? Is this possible in Splunk?
(Numbers 1-5 are just Splunk default table row numbers)&lt;/P&gt;</description>
    <pubDate>Wed, 22 Sep 2010 20:25:12 GMT</pubDate>
    <dc:creator>Ant1D</dc:creator>
    <dc:date>2010-09-22T20:25:12Z</dc:date>
    <item>
      <title>Sort Search Command Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-Search-Command-Question/m-p/55935#M13665</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;

&lt;P&gt;In Splunk, you can sort your search results by field using the sort command.&lt;/P&gt;

&lt;P&gt;Is it possible to sort search results by row?&lt;/P&gt;

&lt;P&gt;E.g. If I have a search that produces the following table:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Day         Total&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;1 Monday         93&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;2 Tuedsay       124&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;3 Thursday      356&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;4 Weekend      1022&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;5 Wednesday     248&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;and what I really want instead is this table below (showing the days in order):&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Day         Total&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;1 Monday         93&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;2 Tuedsay       124&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;3 Wednesday     248&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;4 Thursday      356&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;5 Weekend      1022&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;How would I be able to do this? Is this possible in Splunk?
(Numbers 1-5 are just Splunk default table row numbers)&lt;/P&gt;</description>
      <pubDate>Wed, 22 Sep 2010 20:25:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-Search-Command-Question/m-p/55935#M13665</guid>
      <dc:creator>Ant1D</dc:creator>
      <dc:date>2010-09-22T20:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Sort Search Command Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-Search-Command-Question/m-p/55936#M13666</link>
      <description>&lt;P&gt;I suspect that you need to use rex to create a field for the total and then sort by that field.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Sep 2010 21:18:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-Search-Command-Question/m-p/55936#M13666</guid>
      <dc:creator>christopherutz</dc:creator>
      <dc:date>2010-09-22T21:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: Sort Search Command Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-Search-Command-Question/m-p/55937#M13667</link>
      <description>&lt;P&gt;There is a solution, it's a little complicated though. You would need to create a field that can be sorted on first, since sorting on weekdays would sort in alphabetical order.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | eval wd=lower(Day) | eval sort_field=case(wd=="monday",1,wd=="tuesday",2,wd=="wednesday",3,wd=="thursday",4,wd=="friday",5,wd=="weekend",6) | sort sort_field | fields - sort_field
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Sep 2010 21:51:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-Search-Command-Question/m-p/55937#M13667</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2010-09-22T21:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Sort Search Command Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-Search-Command-Question/m-p/55938#M13668</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Blockquote| eval wd=lower(Day) | eval sort_field=case(wd=="monday",1,wd=="tuesday",2,wd=="wednesday",3,wd=="thursday",4,wd=="friday",5,wd=="weekend",6) | sort sort_field | fields - sort_field &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;ฺbeside you ,change sort_filed to my field name ,What else I change wd value to my field name too ? &lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:29:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-Search-Command-Question/m-p/55938#M13668</guid>
      <dc:creator>jittimat_r</dc:creator>
      <dc:date>2020-09-28T17:29:19Z</dc:date>
    </item>
  </channel>
</rss>

