<?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: OrderBy An Array Of Features in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/orderby-an-array-of-features/m-p/1516816#M60737</link>
    <description>&lt;P&gt;I added the Round function to the distNum var and that worked for getting the decimal places where I want them.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var distNum = Round(Number(dist), 2) &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I just need to sort them. Almost there and thanks so far.&lt;/P&gt;</description>
    <pubDate>Thu, 08 Aug 2024 17:27:32 GMT</pubDate>
    <dc:creator>GregReinecke</dc:creator>
    <dc:date>2024-08-08T17:27:32Z</dc:date>
    <item>
      <title>OrderBy An Array Of Features</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/orderby-an-array-of-features/m-p/1516696#M60728</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;I have written a bit or arcade (I'm by no means a developer) that currently identifies features within a buffer and puts them in an array. From there I identify the Top 4 features that get pulled.&lt;/P&gt;&lt;P&gt;I'm struggling to 1) sort or OrderBy 'DESC' the resulting four features based on the distance (dist) and 2) limit the output to 3 decimal places.&lt;/P&gt;&lt;P&gt;I have attached the code below and the current result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var intersectsLayer = Intersects(FeatureSetByName($map, "InventoryIntersects"),buff)

var devList =[]

for (var f in intersectsLayer){
  var dName = f.Development_Name
  var dist = DistanceGeodetic(f,$feature,'mile')
  var distNum = Number(dist) 
  var distFull = distNum + " miles to the nearest property " + dName 
   Push(devList, distFull)
}

var topProps = Top(devList, 4)

return topProps&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;array(4)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;"0 miles to the nearest property El Patrimonio Apartments"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;"1.144445981353735 miles to the nearest property Padre De Vida Apartments"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;"3.2777811013923253 miles to the nearest property Villas at Beaumont"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;3&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;"2.470305385835081 miles to the nearest property Uvalde Villas"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 08 Aug 2024 14:42:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/orderby-an-array-of-features/m-p/1516696#M60728</guid>
      <dc:creator>GregReinecke</dc:creator>
      <dc:date>2024-08-08T14:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: OrderBy An Array Of Features</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/orderby-an-array-of-features/m-p/1516804#M60733</link>
      <description>&lt;P&gt;What happens if you do:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var topProps = Round(Top(devList, 4), 3)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 16:54:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/orderby-an-array-of-features/m-p/1516804#M60733</guid>
      <dc:creator>Ed_</dc:creator>
      <dc:date>2024-08-08T16:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: OrderBy An Array Of Features</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/orderby-an-array-of-features/m-p/1516807#M60735</link>
      <description>&lt;P&gt;Hi Ed,&lt;/P&gt;&lt;P&gt;I get a number: NaN message. I'm assuming the Round wants a number and devList is an array if I'm understanding of some of this.&amp;nbsp; I'd like to sort on the distNum value and reduce that to a couple decimal places'&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 17:12:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/orderby-an-array-of-features/m-p/1516807#M60735</guid>
      <dc:creator>GregReinecke</dc:creator>
      <dc:date>2024-08-08T17:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: OrderBy An Array Of Features</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/orderby-an-array-of-features/m-p/1516816#M60737</link>
      <description>&lt;P&gt;I added the Round function to the distNum var and that worked for getting the decimal places where I want them.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var distNum = Round(Number(dist), 2) &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I just need to sort them. Almost there and thanks so far.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 17:27:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/orderby-an-array-of-features/m-p/1516816#M60737</guid>
      <dc:creator>GregReinecke</dc:creator>
      <dc:date>2024-08-08T17:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: OrderBy An Array Of Features</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/orderby-an-array-of-features/m-p/1516822#M60738</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/598171"&gt;@GregReinecke&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This OrderBy function should help you out here:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var sortedList = OrderBy(devList, 'dist DESC');&lt;/LI-CODE&gt;&lt;P&gt;For simplicity I named it sortedList, but you can rename it to devList to keep things together.&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 17:41:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/orderby-an-array-of-features/m-p/1516822#M60738</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-08-08T17:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: OrderBy An Array Of Features</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/orderby-an-array-of-features/m-p/1516824#M60739</link>
      <description>&lt;P&gt;Cool that the "Round" function worked&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; now for arranging values in descending order have you tried the "Sort" function? Because the Sort by default arranges values in descending order.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 17:44:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/orderby-an-array-of-features/m-p/1516824#M60739</guid>
      <dc:creator>Ed_</dc:creator>
      <dc:date>2024-08-08T17:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: OrderBy An Array Of Features</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/orderby-an-array-of-features/m-p/1516837#M60741</link>
      <description>&lt;P&gt;Thanks Ed and Cody. It looked like the OrderBy would break on the array but the Sort worked fine (see the last couple lines of the final code. Thanks again!!!&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var buff = Buffer($feature,4,'mile')
var intersectsLayer = Intersects(FeatureSetByName($map, "InventoryIntersects"),buff)

var devList =[]

for (var f in intersectsLayer){
  var dName = f.Development_Name
  var dist = DistanceGeodetic(f,$feature,'mile')
  var distNum = Round(Number(dist), 2) 
  
  var distFull = distNum + " miles to the nearest property " + dName 
   Push(devList, distFull)
}

Sort(devList)
var topProps = Top(devList, 4)
return Sort(topProps); &lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 08 Aug 2024 18:04:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/orderby-an-array-of-features/m-p/1516837#M60741</guid>
      <dc:creator>GregReinecke</dc:creator>
      <dc:date>2024-08-08T18:04:21Z</dc:date>
    </item>
  </channel>
</rss>

