<?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 fields by date in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sort-fields-by-date/m-p/179328#M51615</link>
    <description>&lt;P&gt;Splunk's sort is lexicographical.  Your data as-is won't sort right using a lexicographical approach.  Let's borrow a pattern from Python (who borrowed it from lisp), Decorate-Sort-Undecorate&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=datefield "(?&amp;lt;temp_mon&amp;gt;\d\d)/(?&amp;lt;temp_year&amp;gt;\d\d)"
| sort temp_year, temp_mon
| fields -temp_year,temp_mon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We add two new fields that sort in the right order, do the sort, then throw away the temporary fields.  Result is data sorted like you wanted.&lt;/P&gt;</description>
    <pubDate>Tue, 27 May 2014 14:48:17 GMT</pubDate>
    <dc:creator>dwaddle</dc:creator>
    <dc:date>2014-05-27T14:48:17Z</dc:date>
    <item>
      <title>Sort fields by date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-fields-by-date/m-p/179327#M51614</link>
      <description>&lt;P&gt;Hello There , &lt;/P&gt;

&lt;P&gt;Basically I have some dates in this format : &lt;/P&gt;

&lt;P&gt;01/13     700&lt;BR /&gt;
02/13     600&lt;BR /&gt;
...&lt;BR /&gt;
01/14     500&lt;/P&gt;

&lt;P&gt;I use these fields for a chart&lt;/P&gt;

&lt;P&gt;I wanna sort them in calendar order but I get &lt;/P&gt;

&lt;P&gt;01/14    531&lt;BR /&gt;
02/14    513&lt;BR /&gt;
03/14    545&lt;BR /&gt;
04/13    145&lt;BR /&gt;
04/14    94&lt;BR /&gt;
05/13    198&lt;BR /&gt;
06/13    14&lt;BR /&gt;
07/13    143&lt;BR /&gt;
08/13    1234&lt;BR /&gt;
09/13    899&lt;BR /&gt;
10/13    508&lt;BR /&gt;
11/13    33&lt;/P&gt;

&lt;P&gt;Could you Help me ?&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2014 14:42:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-fields-by-date/m-p/179327#M51614</guid>
      <dc:creator>baranova</dc:creator>
      <dc:date>2014-05-27T14:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: Sort fields by date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-fields-by-date/m-p/179328#M51615</link>
      <description>&lt;P&gt;Splunk's sort is lexicographical.  Your data as-is won't sort right using a lexicographical approach.  Let's borrow a pattern from Python (who borrowed it from lisp), Decorate-Sort-Undecorate&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=datefield "(?&amp;lt;temp_mon&amp;gt;\d\d)/(?&amp;lt;temp_year&amp;gt;\d\d)"
| sort temp_year, temp_mon
| fields -temp_year,temp_mon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We add two new fields that sort in the right order, do the sort, then throw away the temporary fields.  Result is data sorted like you wanted.&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2014 14:48:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-fields-by-date/m-p/179328#M51615</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2014-05-27T14:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sort fields by date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-fields-by-date/m-p/179329#M51616</link>
      <description>&lt;P&gt;Hello dwaddle and thanks for your quick answer. Works like a charm!&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2014 14:56:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-fields-by-date/m-p/179329#M51616</guid>
      <dc:creator>baranova</dc:creator>
      <dc:date>2014-05-27T14:56:56Z</dc:date>
    </item>
  </channel>
</rss>

