<?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 column header is based on ASCII and its not based on case senstitve in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407172#M117610</link>
    <description>&lt;P&gt;I don' think this is possible without writing a custom Javascript and implementing that into your dashboard...&lt;/P&gt;</description>
    <pubDate>Tue, 22 May 2018 19:06:37 GMT</pubDate>
    <dc:creator>xpac</dc:creator>
    <dc:date>2018-05-22T19:06:37Z</dc:date>
    <item>
      <title>Sorting column header is based on ASCII and its not based on case senstitve</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407171#M117609</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I have a saved search with the below code snippet to sort irrespective of case.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=indexname 
| eval sortName = lower(Name)
| sort sortName 
| table Name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But when I click on 'Name' column header, its sorting based on ASCII. &lt;BR /&gt;
How to make it sort irrespective of case? Is it really possible? Please help.&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 18:21:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407171#M117609</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-05-22T18:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting column header is based on ASCII and its not based on case senstitve</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407172#M117610</link>
      <description>&lt;P&gt;I don' think this is possible without writing a custom Javascript and implementing that into your dashboard...&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 19:06:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407172#M117610</guid>
      <dc:creator>xpac</dc:creator>
      <dc:date>2018-05-22T19:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting column header is based on ASCII and its not based on case senstitve</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407173#M117611</link>
      <description>&lt;P&gt;Splunk sort on string columns are based on ASCII value. You create a new field sortName with all lowercase and to an explicit sort on that field, but the value of field Name is unchanged. Hence when you click on Name columns, it still gets sorted based on it's value.&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 19:12:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407173#M117611</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-05-22T19:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting column header is based on ASCII and its not based on case senstitve</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407174#M117612</link>
      <description>&lt;P&gt;@angelinealex would it be of any use to you if Sorting option was removed from the &lt;CODE&gt;Name&lt;/CODE&gt; Table column? Or else can you use &lt;CODE&gt;lower()&lt;/CODE&gt; or &lt;CODE&gt;upper()&lt;/CODE&gt; case values in the Name field itself?&lt;/P&gt;

&lt;P&gt;If not like it was suggested by @xpac, Simple XML JavaScript extension may be your option to apply sorting as per your need.&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 19:52:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407174#M117612</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-22T19:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting column header is based on ASCII and its not based on case senstitve</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407175#M117613</link>
      <description>&lt;P&gt;Requirement is to sort based on Name column only and I dont want loose the case value for Name field. So I cant use lower() or upper() to the Name field.&lt;/P&gt;

&lt;P&gt;Can you add some sample code to achieve this using XML Javascript extension?&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 20:06:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407175#M117613</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-05-22T20:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting column header is based on ASCII and its not based on case senstitve</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407176#M117614</link>
      <description>&lt;P&gt;Can you add some sample code to achieve this using custom Javascript?&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 20:08:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407176#M117614</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-05-22T20:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting column header is based on ASCII and its not based on case senstitve</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407177#M117615</link>
      <description>&lt;P&gt;How about you add a columns &lt;CODE&gt;sno&lt;/CODE&gt; which contains the serial number of rows after sorting based on lower(Name) value? This will allow your users to sort Name columns ascending/descending order (by clicking on sno column), like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=indexname 
 | eval sortName = lower(Name)
 | sort sortName | streamstats count as sno
 | table sno Name
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 May 2018 21:11:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407177#M117615</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-05-22T21:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting column header is based on ASCII and its not based on case senstitve</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407178#M117616</link>
      <description>&lt;P&gt;I cant add new column as that is not part of requirement. Using this saved search to show as report to the customer.&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 17:52:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407178#M117616</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-05-23T17:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting column header is based on ASCII and its not based on case senstitve</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407179#M117617</link>
      <description>&lt;P&gt;@angelinealex, please try out the following Run any where dashboard with Simple XML JS extension. This actually builds up on @somesoni2 's answer. Prefix Sno to Name after sorting using lower case values. Then use Splunk JS Stack to apply custom Cell Render. In the JavaScript code, I am stripping off Serial Number before displaying in the table using regular expression.&lt;/P&gt;

&lt;P&gt;First Table is mocks the issue where sorting is Case sensitive.&lt;/P&gt;

&lt;P&gt;Second Table is the solution by Somesh Soni to prefix Serial Number before Values to always have them sorted. PS: &lt;CODE&gt;prinf()&lt;/CODE&gt; function has been used to pad extra zero to keep digits sorted i.e. instead of &lt;CODE&gt;1, 10,11,... 2,3,4...&lt;/CODE&gt; have &lt;CODE&gt;01,02,03,04...,10,11&lt;/CODE&gt;. Padding can be increased as per total count or rows.&lt;/P&gt;

&lt;P&gt;Third Table is one with Custom Cell Renderer using &lt;CODE&gt;&amp;lt;table&amp;gt;&lt;/CODE&gt; id &lt;CODE&gt;tableWithAlphabeticalSort&lt;/CODE&gt;, which strips the prefixed serial number using &lt;CODE&gt;Simple XML JS&lt;/CODE&gt; extension and &lt;CODE&gt;Splunk JS Stack&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4988i640108BD4906EEAD/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Following is the Simple XML code for run anywhere dashboard:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="table_with_alphabet_sort.js"&amp;gt;
  &amp;lt;label&amp;gt;Table Alphabetically Case Insensitive sort&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="tableWithCaseSensitiveSorting"&amp;gt;
        &amp;lt;title&amp;gt;Table without Case Sensitive Sorting&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults 
| eval Name="apple,Aeroplane,Bat,bolt" 
| makemv Name delim="," 
| mvexpand Name 
| eval sortName = lower(Name) 
| sort sortName
| table Name sortName&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="tableWithoutCustomCellSorting"&amp;gt;
        &amp;lt;title&amp;gt;Table without JS for Case Insensitive Sort&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults 
| eval Name="apple,Aeroplane,Bat,bolt" 
| makemv Name delim="," 
| mvexpand Name 
| eval sortName = lower(Name) 
| sort sortName 
| streamstats count as sno
| eval sno=printf("%02d",sno)
| eval Name=sno.".".Name 
| table Name sortName&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="tableWithAlphabeticalSort"&amp;gt;
        &amp;lt;title&amp;gt;Table with Case Insensitive Sorting&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults 
| eval Name="apple,Aeroplane,Bat,bolt" 
| makemv Name delim="," 
| mvexpand Name 
| eval sortName = lower(Name) 
| sort sortName 
| streamstats count as sno
| eval sno=printf("%02d",sno)
| eval Name=sno.".".Name 
| table Name sortName&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is the code for JavaScript file &lt;CODE&gt;table_with_alphabet_sort.js&lt;/CODE&gt; to be placed under your app's &lt;CODE&gt;appserver/static&lt;/CODE&gt; folder:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'underscore',
    'jquery',
    'splunkjs/mvc',
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {

    var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
        canRender: function(cell) {
            // Enable this custom cell renderer for Name field
            return _(['Name']).contains(cell.field);
        },
        render: function($td, cell) {
            // Extract Numeric Part for Sorting and Hide Using CSS
            // Keep Name as Text strName
            var value = cell.value;
            var snoPrefix = value.match(/\d+\./);
            var strName = value.match(/[^\d\.]+/);

            // Create HTML with Numeric sno hidden and Name displayed
            $td.text(strName).addClass('string');
        }
    });

    mvc.Components.get("tableWithAlphabeticalSort").getVisualization(function(tableView) {
        tableView.on('rendered', function() {
            setTimeout(function(){
                // Add custom cell renderer, the table will re-render automatically.
                tableView.addCellRenderer(new CustomRangeRenderer());
            },100);
        });
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please try out and confirm!&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 18:55:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407179#M117617</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-23T18:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting column header is based on ASCII and its not based on case senstitve</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407180#M117618</link>
      <description>&lt;P&gt;@niketnilay, Thank you for the detailed example. Currently am stuck up with some other priority work. I will try and update you. Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 16:06:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-column-header-is-based-on-ASCII-and-its-not-based-on/m-p/407180#M117618</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-05-29T16:06:08Z</dc:date>
    </item>
  </channel>
</rss>

