<?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 Re: Sort in  an order in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sort-in-an-order/m-p/519822#M146392</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;the easiest way is convert date as epoch then sort with it and then remove/hide that field.&lt;/P&gt;&lt;PRE&gt;...
| eval sTime = substr(your_field, 1, 6), rTime = substr(your_field, 7)
| eval sTime = strptime(sTime, "%d %b")
| sort sTime, rTime
| fields - sTime, rTime &lt;/PRE&gt;&lt;P&gt;r. Ismo&lt;/P&gt;</description>
    <pubDate>Wed, 16 Sep 2020 05:34:19 GMT</pubDate>
    <dc:creator>isoutamo</dc:creator>
    <dc:date>2020-09-16T05:34:19Z</dc:date>
    <item>
      <title>Sort in  an order</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-in-an-order/m-p/519817#M146391</link>
      <description>&lt;DIV&gt;Is there a way to sort field&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="Segoe UI" color="#000000"&gt;&lt;SPAN&gt;09 Sep-256789 in descending&amp;nbsp;order?&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Segoe UI" color="#000000"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Segoe UI" color="#000000"&gt;&lt;SPAN&gt;For example, if we have sample fields 10 Sep-26789&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;,31 Aug- 256670 , 09 Sep-256789 . It should sort in order&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Segoe UI" color="#000000"&gt;&lt;SPAN&gt;&lt;STRONG&gt;Before Sort&lt;/STRONG&gt;&amp;nbsp;-10 Sep-26789&amp;nbsp;&amp;nbsp;, 09 Sep-256789&amp;nbsp; ,31 Aug- 256670&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;After Sort-&amp;nbsp; &lt;/STRONG&gt;31 Aug- 256670 ,&amp;nbsp; 09 Sep-256789&amp;nbsp; ,&amp;nbsp;&amp;nbsp;&lt;FONT face="Segoe UI" color="#000000"&gt;10 Sep-26789&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Number '&lt;FONT face="Segoe UI" color="#000000"&gt;&lt;SPAN&gt;26789 ' attached to month is a random number .&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 16 Sep 2020 05:14:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-in-an-order/m-p/519817#M146391</guid>
      <dc:creator>romansha</dc:creator>
      <dc:date>2020-09-16T05:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: Sort in  an order</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-in-an-order/m-p/519822#M146392</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;the easiest way is convert date as epoch then sort with it and then remove/hide that field.&lt;/P&gt;&lt;PRE&gt;...
| eval sTime = substr(your_field, 1, 6), rTime = substr(your_field, 7)
| eval sTime = strptime(sTime, "%d %b")
| sort sTime, rTime
| fields - sTime, rTime &lt;/PRE&gt;&lt;P&gt;r. Ismo&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 05:34:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-in-an-order/m-p/519822#M146392</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-09-16T05:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Sort in  an order</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-in-an-order/m-p/519828#M146395</link>
      <description>&lt;P&gt;If you want to order columns in that date order, then you cannot sort columns. You can use&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| table a b c d e f&lt;/LI-CODE&gt;&lt;P&gt;but that's probably not useful, so in the past I have used transpose to turn columns to values, then sort the values (first converting them to dates) and then transpose back to columns, along the lines of&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval cols=split("10 Sep-26789,09 Sep-256789,31 Aug-256670,10 Sep-26780",",")
| mvexpand cols
| eval mydata=random()
| fields - _time
| eval d=strptime(cols,"%d %b")
| rex field=cols "-(?&amp;lt;id&amp;gt;\d+)"
| sort d id
| transpose 0 header_field=cols&lt;/LI-CODE&gt;&lt;P&gt;See how the transpose at the end converts the sorted cols field back to columns in the right order.&lt;/P&gt;&lt;P&gt;Not sure how this will work with your data though.&lt;/P&gt;&lt;P&gt;If you are actually talking about field values with those values, then the last part will do the sort, i.e.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval d=strptime(cols,"%d %b")
| rex field=cols "-(?&amp;lt;id&amp;gt;\d+)"
| sort d id&lt;/LI-CODE&gt;&lt;P&gt;of course, you don't have a year, so that will not work around Dec/Jan. The rex statement is just to correctly sort those random ids if there is the same date.&lt;/P&gt;&lt;P&gt;Hope this is useful&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 05:53:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-in-an-order/m-p/519828#M146395</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-09-16T05:53:42Z</dc:date>
    </item>
  </channel>
</rss>

