<?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: Does Arcade support multi-dimentional arrays? in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/does-arcade-support-multi-dimentional-arrays/m-p/1405515#M58462</link>
    <description>&lt;P&gt;To follow up myself once again, you can sort the multi-dimensional array inside Arcade as well. The sort function below will sort in ascending order:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var a = [];
push(a,['Bahamas',22.5,5.78]);
push(a,['Cuba',10.2,2.9]);
push(a,['Argentina',4.6,1.1]);

function SortDesc(a,b){
  if (a[1]&amp;lt;b[1])
    return -1;
  if (a[1]&amp;gt;b[1])
    return 1;
  return 0;
}

var aSort = Sort(a,SortDesc);

Console(a[0]);
Console('The first column is: ' + a[0][0]);
Console('The second column is: ' + a[0][1]);
Console('The third column is: ' + a[0][2]);

Console(aSort[0]);
Console(aSort[1]);
Console(aSort[2]);

for(var index in aSort){
  Console(aSort[index][0]);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want descending order like I did, you simply reverse the order of the returned value in the function like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function SortDesc(a,b){
  if (a[1]&amp;lt;b[1])
    return 1;
  if (a[1]&amp;gt;b[1])
    return -1;
  return 0;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although you reference array[][] using the double brackets in most parts of the code, the function only needs one set of brackets for the column. Happy hackling!..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Apr 2024 22:44:45 GMT</pubDate>
    <dc:creator>SteveCole</dc:creator>
    <dc:date>2024-04-03T22:44:45Z</dc:date>
    <item>
      <title>Does Arcade support multi-dimentional arrays?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/does-arcade-support-multi-dimentional-arrays/m-p/1405367#M58457</link>
      <description>&lt;P&gt;I have some pop up logic written in for the Javascript API but I want to port that over to AGOL/Portal Web Map popups but my content logic revolves around the use of multi-dimensional arrays. I don't see anything explicitly stated in the documentation hence this post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The context for this is that I have a census data layer which has 150 attribute fields with count values. For each non-zero value, it is added to a multi-dimensional array where the 1st column is a label, the second is the percentage based on a total population subset, and the third column in the array is the percentage based on the entire population of the census tract.&lt;/P&gt;&lt;P&gt;Once the array is fully populated, I sort the array in descending value order based on the 2nd column of the array and then build out an HTML table for the pop up. Anyways, I can do this in the JS API because it's pure JS but I'm not sure about Arcade.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 18:19:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/does-arcade-support-multi-dimentional-arrays/m-p/1405367#M58457</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2024-04-03T18:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: Does Arcade support multi-dimentional arrays?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/does-arcade-support-multi-dimentional-arrays/m-p/1405453#M58460</link>
      <description>&lt;P&gt;In answer to my own question, the answer appears to be yes, they are supported. A simple test case:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="arcade_2d_array_ex.jpg" style="width: 902px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/99949iA9283DF79D3EE9A2/image-size/large?v=v2&amp;amp;px=999" role="button" title="arcade_2d_array_ex.jpg" alt="arcade_2d_array_ex.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Not sure about sorting it but I guess that's the next thing to tackle..&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 20:35:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/does-arcade-support-multi-dimentional-arrays/m-p/1405453#M58460</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2024-04-03T20:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Does Arcade support multi-dimentional arrays?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/does-arcade-support-multi-dimentional-arrays/m-p/1405515#M58462</link>
      <description>&lt;P&gt;To follow up myself once again, you can sort the multi-dimensional array inside Arcade as well. The sort function below will sort in ascending order:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var a = [];
push(a,['Bahamas',22.5,5.78]);
push(a,['Cuba',10.2,2.9]);
push(a,['Argentina',4.6,1.1]);

function SortDesc(a,b){
  if (a[1]&amp;lt;b[1])
    return -1;
  if (a[1]&amp;gt;b[1])
    return 1;
  return 0;
}

var aSort = Sort(a,SortDesc);

Console(a[0]);
Console('The first column is: ' + a[0][0]);
Console('The second column is: ' + a[0][1]);
Console('The third column is: ' + a[0][2]);

Console(aSort[0]);
Console(aSort[1]);
Console(aSort[2]);

for(var index in aSort){
  Console(aSort[index][0]);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want descending order like I did, you simply reverse the order of the returned value in the function like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function SortDesc(a,b){
  if (a[1]&amp;lt;b[1])
    return 1;
  if (a[1]&amp;gt;b[1])
    return -1;
  return 0;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although you reference array[][] using the double brackets in most parts of the code, the function only needs one set of brackets for the column. Happy hackling!..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 22:44:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/does-arcade-support-multi-dimentional-arrays/m-p/1405515#M58462</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2024-04-03T22:44:45Z</dc:date>
    </item>
  </channel>
</rss>

