<?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: Sorting issue with numeric field, descending order in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sorting-issue-with-numeric-field-descending-order/m-p/484753#M135693</link>
    <description>&lt;P&gt;Try forcing splunk to treat the ID field as a number.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| sort -num(id)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.3/SearchReference/Sort"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.3/SearchReference/Sort&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Apr 2020 17:19:31 GMT</pubDate>
    <dc:creator>dsctm3</dc:creator>
    <dc:date>2020-04-29T17:19:31Z</dc:date>
    <item>
      <title>Sorting issue with numeric field, descending order</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-issue-with-numeric-field-descending-order/m-p/484752#M135692</link>
      <description>&lt;P&gt;I have a simple search with a sort command at the end as follows:&lt;BR /&gt;
.... some base search  &lt;CODE&gt;| dedup id | table id, name | sort -id&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;
and I'm being presented with the following results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;18760000000000166   2020 Summer
18760000000000168   2020 Fall
18760000000000167   2020-2021 Academic Year
18760000000000164   2020 Winter
18760000000000165   2020 Spring
18760000000000163   2019 Fall
18760000000000131   2019-2020 Academic Year
18760000000000127   2019 Spring
18760000000000129   2019-2020 Academic Year
18760000000000130   2018-2019 Academic Year
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I expected the results to have been ordered by id  (descending order). What am I missing?  &lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 17:05:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-issue-with-numeric-field-descending-order/m-p/484752#M135692</guid>
      <dc:creator>pgoldweic</dc:creator>
      <dc:date>2020-04-29T17:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting issue with numeric field, descending order</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-issue-with-numeric-field-descending-order/m-p/484753#M135693</link>
      <description>&lt;P&gt;Try forcing splunk to treat the ID field as a number.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| sort -num(id)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.3/SearchReference/Sort"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.3/SearchReference/Sort&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 17:19:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-issue-with-numeric-field-descending-order/m-p/484753#M135693</guid>
      <dc:creator>dsctm3</dc:creator>
      <dc:date>2020-04-29T17:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting issue with numeric field, descending order</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-issue-with-numeric-field-descending-order/m-p/484754#M135694</link>
      <description>&lt;P&gt;Thanks for your reply. I just tried your suggestion but it's not working (gives me identical results!).&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 17:52:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-issue-with-numeric-field-descending-order/m-p/484754#M135694</guid>
      <dc:creator>pgoldweic</dc:creator>
      <dc:date>2020-04-29T17:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting issue with numeric field, descending order</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-issue-with-numeric-field-descending-order/m-p/484755#M135695</link>
      <description>&lt;P&gt;Solution:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="id,name
18760000000000166,2020 Summer
18760000000000168,2020 Fall
18760000000000167,2020-2021 Academic Year
18760000000000164,2020 Winter
18760000000000165,2020 Spring
18760000000000163,2019 Fall
18760000000000131,2019-2020 Academic Year
18760000000000127,2019 Spring
18760000000000129,2019-2020 Academic Year
18760000000000130,2018-2019 Academic Year"
| multikv forceheader=1
| table id name
| rex field=id "(?&amp;lt;Upper&amp;gt;\d{10})(?&amp;lt;Lower&amp;gt;\d{7})"
| sort - Upper Lower
| fields - Upper Lower
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;that's interesting.&lt;/P&gt;

&lt;P&gt;sample:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="id,name
18760000000000166,2020 Summer
18760000000000168,2020 Fall
18760000000000167,2020-2021 Academic Year
18760000000000164,2020 Winter
18760000000000165,2020 Spring
18760000000000163,2019 Fall
18760000000000131,2019-2020 Academic Year
18760000000000127,2019 Spring
18760000000000129,2019-2020 Academic Year
18760000000000130,2018-2019 Academic Year"
| multikv forceheader=1
| table id name
| eval check = tonumber(id)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;id&lt;/CODE&gt; is huge number. so Splunk has rounded off the number.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 18:41:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-issue-with-numeric-field-descending-order/m-p/484755#M135695</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-29T18:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting issue with numeric field, descending order</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-issue-with-numeric-field-descending-order/m-p/484756#M135696</link>
      <description>&lt;P&gt;Oh, I see. It didn't occur to me that Splunk could be rounding out, but it now makes sense. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 18:44:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-issue-with-numeric-field-descending-order/m-p/484756#M135696</guid>
      <dc:creator>pgoldweic</dc:creator>
      <dc:date>2020-04-29T18:44:47Z</dc:date>
    </item>
  </channel>
</rss>

