<?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: Default Table sort order not working as expected in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213210#M62536</link>
    <description>&lt;P&gt;Are you sure? This works fine:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | head 10 | table _time sourcetype | sort + _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Use 1:n event sampling to get reasonable spaces in your timestamps if the last ten events all have the same.&lt;/P&gt;</description>
    <pubDate>Sat, 23 Apr 2016 15:04:02 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2016-04-23T15:04:02Z</dc:date>
    <item>
      <title>Default Table sort order not working as expected?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213200#M62526</link>
      <description>&lt;PRE&gt;&lt;CODE&gt; host="*" index=main sourcetype=WwanSignal uid="3F77F61645E8323E205F832212" | table _time deviceName user quality prevQuality prevDuration RSRP RSRQ RSSI SINR SQ lat lon
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is returning in this sort order. Why is _time not sorting as expected, newest to oldest? Running 6.4.0. I though by default sort is base on _time field newest to oldest.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/1262i9641E11DC132C4E6/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 13:32:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213200#M62526</guid>
      <dc:creator>simpkins1958</dc:creator>
      <dc:date>2022-10-04T13:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Default Table sort order not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213201#M62527</link>
      <description>&lt;P&gt;Tables don't auto sort to my knowledge.  Just add a |sort - _time and that should work.  Or maybe you're looking for | sort _time   You did mention descending time newest to oldest... So I think you want the positive sort not the negative sort.&lt;/P&gt;

&lt;P&gt;The docs specifically say not to use table if you want the internal fields like _time.  &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.0/SearchReference/Table"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.0/SearchReference/Table&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host="*" index=main sourcetype=WwanSignal uid="3F77F61645E8323E205F832212" | table _time deviceName user quality prevQuality prevDuration RSRP RSRQ RSSI SINR SQ lat lon | sort _time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Apr 2016 23:40:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213201#M62527</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-04-22T23:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Default Table sort order not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213202#M62528</link>
      <description>&lt;P&gt;This is the way i do, creating a custom field in epochtime, sorting on this field and removing it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval time=strftime('_time', "%s") | sort - time | fields - time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval time=strftime('_time', "%s") | sort time | fields - time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sorting by an integer will always work as expected.&lt;/P&gt;

&lt;P&gt;Note that sort will truncate to 10.000 output, if you want more:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sort limit=0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Apr 2016 00:23:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213202#M62528</guid>
      <dc:creator>guilmxm</dc:creator>
      <dc:date>2016-04-23T00:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: Default Table sort order not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213203#M62529</link>
      <description>&lt;P&gt;This should not be necessary, underneath the UI formatting &lt;CODE&gt;_time&lt;/CODE&gt; already is an epoch.subsecond value. Restricting this to &lt;CODE&gt;%s&lt;/CODE&gt; would in fact reduce sortability by discarding the subsecond.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2016 13:35:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213203#M62529</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-04-23T13:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Default Table sort order not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213204#M62530</link>
      <description>&lt;P&gt;The docs note about not using &lt;CODE&gt;table&lt;/CODE&gt; for internal fields starting with an underscore doesn't mean you shouldn't use &lt;CODE&gt;table&lt;/CODE&gt; to display &lt;CODE&gt;_time&lt;/CODE&gt;.&lt;BR /&gt;
Instead, you should not do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | timechart count by sourcetype | table _time splunkd
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This would drop the hidden &lt;CODE&gt;timechart&lt;/CODE&gt; field &lt;CODE&gt;_span&lt;/CODE&gt; that is needed by the charting engine to display the axis labels correctly.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2016 13:38:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213204#M62530</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-04-23T13:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: Default Table sort order not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213205#M62531</link>
      <description>&lt;P&gt;That makes more sense.  Frankly I was surprised to see the new docs on table.  I rarely if at all look at documents for the table command and I was pleasantly surprised to see the new format of docs etc.  I read the cautionary statement wrong and thought it was new to 6.4 but I also see it in previous versions too.  &lt;/P&gt;

&lt;P&gt;So my final answer is the | sort _time&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2016 14:10:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213205#M62531</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-04-23T14:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Default Table sort order not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213206#M62532</link>
      <description>&lt;P&gt;Are my thoughts correct in that I beleive the op is getting out of order results due to an index cluster or multiple indexers returning results and the table command is just presenting them as they arrived at the search heads and in the order they were received?&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2016 14:17:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213206#M62532</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-04-23T14:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: Default Table sort order not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213207#M62533</link>
      <description>&lt;P&gt;Pretty much. &lt;CODE&gt;table&lt;/CODE&gt; in and of itself doesn't guarantee any sorting. It switches from events to results... events are sorted by Splunk in reverse time order , results can be anything.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2016 14:20:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213207#M62533</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-04-23T14:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: Default Table sort order not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213208#M62534</link>
      <description>&lt;P&gt;switches from events to results is the key then.  Thanks Martin!&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2016 14:41:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213208#M62534</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-04-23T14:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Default Table sort order not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213209#M62535</link>
      <description>&lt;P&gt;It is necessary if the desired output is a table, and not event.&lt;BR /&gt;
He can always create a field in epochtime with subsecond ("%s.%f") to keep the subsecond accuracy.&lt;BR /&gt;
_time is in deed already epochtime, but it cannot be used to sort within a table in a view for example.&lt;/P&gt;

&lt;P&gt;Sometimes you will want a view with a table (and not event), and some evaluations sorted by the original time or a custom time, therefore it is not appropriated to sort raw events that's right...&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2016 14:51:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213209#M62535</guid>
      <dc:creator>guilmxm</dc:creator>
      <dc:date>2016-04-23T14:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Default Table sort order not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213210#M62536</link>
      <description>&lt;P&gt;Are you sure? This works fine:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | head 10 | table _time sourcetype | sort + _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Use 1:n event sampling to get reasonable spaces in your timestamps if the last ten events all have the same.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2016 15:04:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213210#M62536</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-04-23T15:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: Default Table sort order not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213211#M62537</link>
      <description>&lt;P&gt;In a table within a view ? Or in search ?&lt;BR /&gt;
Within a table in a view, sorting by the _time will not work as expected as far as i know&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2016 15:34:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213211#M62537</guid>
      <dc:creator>guilmxm</dc:creator>
      <dc:date>2016-04-23T15:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Default Table sort order not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213212#M62538</link>
      <description>&lt;P&gt;I'm looking for an example to illustrate... maybe i'm wrong &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2016 15:58:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213212#M62538</guid>
      <dc:creator>guilmxm</dc:creator>
      <dc:date>2016-04-23T15:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Default Table sort order not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213213#M62539</link>
      <description>&lt;P&gt;I tried both in search and on a dashboard, both work as expected for both sort orders.&lt;/P&gt;

&lt;P&gt;If you see something different and sorting doesn't work as expected, do file a bug with support.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2016 16:42:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213213#M62539</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-04-23T16:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Default Table sort order not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213214#M62540</link>
      <description>&lt;P&gt;This behavior is common when the search is made against clustered indexers. The results seem to be returned in chunks from each indexer so overall the events are not strictly in order by time.&lt;/P&gt;

&lt;P&gt;For testing, adding "splunk_server" to the list of fields in the table command should show this.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 23:54:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/213214#M62540</guid>
      <dc:creator>templets</dc:creator>
      <dc:date>2017-06-01T23:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: Default Table sort order not working as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/615817#M213992</link>
      <description>&lt;P&gt;TLDR;&amp;nbsp; seems that&amp;nbsp;&lt;EM&gt;stats list(x)&lt;/EM&gt; as well as &lt;EM&gt;table&lt;/EM&gt; commands return the events in the order they were indexed.&lt;/P&gt;&lt;P&gt;I may be flogging a dead horse here but I thought to add my two cents after investigating the same topic recently. It is still relevant and helps to be aware of this behavior.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For my use case, I generated sample data and indexed it to a single Splunk Enterprise 9.0.1 instance. (So index clustering is not the culprit )&lt;/P&gt;&lt;P&gt;I noticed that the values/rows returned in my &lt;EM&gt;stats list(x)&lt;/EM&gt; and&amp;nbsp;&lt;EM&gt;table&lt;/EM&gt; commands are ordered the same but not correctly by time. But when you do a search that just return the events, they are ordered correctly by _time as usual.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I realized that the events returned from the commands are ordered the same as the events in the input file and therefore the order they were indexed in.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is of course a moot point when the data source is chronological making this one quite sneaky.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 12:45:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Default-Table-sort-order-not-working-as-expected/m-p/615817#M213992</guid>
      <dc:creator>stefan_dt</dc:creator>
      <dc:date>2022-10-04T12:45:37Z</dc:date>
    </item>
  </channel>
</rss>

