<?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 How come table columns get sorted alphabetically and not by their position in capabilities.json? in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/How-come-table-columns-get-sorted-alphabetically-and-not-by/m-p/245019#M7635</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my capabilities.json:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "dataRoles": [
    {
      "displayName": "Name",
      "name": "name",
      "kind": "Grouping"
    },
    {
      "displayName": "Description",
      "name": "description",
      "kind": "Grouping"
    },
    {
      "displayName": "Sector",
      "name": "sector",
      "kind": "Grouping"
    },
    {
      "displayName": "Ring",
      "name": "ring",
      "kind": "Grouping"
    },
    {
      "displayName": "Is new?",
      "name": "isNew",
      "kind": "Grouping"
    }
  ],
  "dataViewMappings": [
    {
      "table": {
        "rows": {
          "select": [
            {
              "for": {
                "in": "name"
              }
            },
            {
              "for": {
                "in": "description"
              }
            },
            {
              "for": {
                "in": "sector"
              }
            },
            {
              "for": {
                "in": "ring"
              }
            },
            {
              "for": {
                "in": "isNew"
              }
            }
          ]
        }
      }
    }
  ]
}&lt;/PRE&gt;&lt;P&gt;However, in my visual, when I run console.log(dataViews[0].table.rows), I see that for each row, it provides the description first, then isNew, name and ring, and finally sector. I presume it is sorting these alphabetically rather than a random sort and it appearing this way by coincidence - but either way, the fact remains that this order is pretty much useless to me as a developer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact, it's not even sorted by the column names that I define - it's sorted by the column names that the user defines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would expect that because I defined name first in capabilities.json, it would appear as the first column of each row, so for example to get the name of the first row I would use dataViews[0].table.rows[0][0]. But with this method of ordering I don't actually know what index the name will be at.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I get around this issue?&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Sep 2017 09:17:31 GMT</pubDate>
    <dc:creator>callum</dc:creator>
    <dc:date>2017-09-04T09:17:31Z</dc:date>
    <item>
      <title>How come table columns get sorted alphabetically and not by their position in capabilities.json?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-come-table-columns-get-sorted-alphabetically-and-not-by/m-p/245019#M7635</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my capabilities.json:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "dataRoles": [
    {
      "displayName": "Name",
      "name": "name",
      "kind": "Grouping"
    },
    {
      "displayName": "Description",
      "name": "description",
      "kind": "Grouping"
    },
    {
      "displayName": "Sector",
      "name": "sector",
      "kind": "Grouping"
    },
    {
      "displayName": "Ring",
      "name": "ring",
      "kind": "Grouping"
    },
    {
      "displayName": "Is new?",
      "name": "isNew",
      "kind": "Grouping"
    }
  ],
  "dataViewMappings": [
    {
      "table": {
        "rows": {
          "select": [
            {
              "for": {
                "in": "name"
              }
            },
            {
              "for": {
                "in": "description"
              }
            },
            {
              "for": {
                "in": "sector"
              }
            },
            {
              "for": {
                "in": "ring"
              }
            },
            {
              "for": {
                "in": "isNew"
              }
            }
          ]
        }
      }
    }
  ]
}&lt;/PRE&gt;&lt;P&gt;However, in my visual, when I run console.log(dataViews[0].table.rows), I see that for each row, it provides the description first, then isNew, name and ring, and finally sector. I presume it is sorting these alphabetically rather than a random sort and it appearing this way by coincidence - but either way, the fact remains that this order is pretty much useless to me as a developer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact, it's not even sorted by the column names that I define - it's sorted by the column names that the user defines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would expect that because I defined name first in capabilities.json, it would appear as the first column of each row, so for example to get the name of the first row I would use dataViews[0].table.rows[0][0]. But with this method of ordering I don't actually know what index the name will be at.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I get around this issue?&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 09:17:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-come-table-columns-get-sorted-alphabetically-and-not-by/m-p/245019#M7635</guid>
      <dc:creator>callum</dc:creator>
      <dc:date>2017-09-04T09:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: How come table columns get sorted alphabetically and not by their position in capabilities.json?</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-come-table-columns-get-sorted-alphabetically-and-not-by/m-p/245749#M7656</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="36706" data-lia-user-login="callum" class="lia-mention lia-mention-user"&gt;callum&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check "options.dataViews[0].table.columns[0].roles".&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 11:02:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-come-table-columns-get-sorted-alphabetically-and-not-by/m-p/245749#M7656</guid>
      <dc:creator>v-chuncz-msft</dc:creator>
      <dc:date>2017-09-05T11:02:43Z</dc:date>
    </item>
  </channel>
</rss>

