<?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: Arcade sorting text help - popup in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1302993#M53066</link>
    <description>&lt;P&gt;This feels closer to what I'm trying to do, but now I can't get the sort to work. Am I doing something wrong?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// create 250mi buffer on selection
var buff = Buffer($feature, 250, 'miles')

// get intersecting staff locations
var staff = Intersects(buff, FeatureSetByName($map, "CS Staff Locations"))

// create empty featureset to hold results
var New_FS = {fields:[        
        {'name':'StaffLocation','type': 'esriFieldTypeString'},
        {'name':'SLDistance','type': 'esriFieldTypeDouble'}],
        'geometryType': '',
        'features':[]
        }
 
for (var s in staff){
    var dist = Distance(s,$feature,'miles')
    var new_f = {'attributes': {'StaffLocation': s['Location'] ,
                                'SLDistance': dist}
                 }
    Push(New_FS.features, new_f)}

var sorted= Top(OrderBy(New_FS, 'SLDistance ASC'),3)

return sorted&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Jun 2023 14:10:54 GMT</pubDate>
    <dc:creator>HarrisonBrown7</dc:creator>
    <dc:date>2023-06-26T14:10:54Z</dc:date>
    <item>
      <title>Arcade sorting text help - popup</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1302120#M53019</link>
      <description>&lt;P&gt;Hello, I am trying to display the closest 3 points (staff locations) to a given feature in a popup. I would like them arranged in order of distance. I have a working expression to show me ALL points within a buffer of the feature, but I just can't figure out how to arrange and truncate them without messing up my resulting string.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any tips? TYIA&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-06-22 115256.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/73961iB59DF3F71F7731C6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2023-06-22 115256.png" alt="Screenshot 2023-06-22 115256.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 16:54:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1302120#M53019</guid>
      <dc:creator>HarrisonBrown7</dc:creator>
      <dc:date>2023-06-22T16:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade sorting text help - popup</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1302123#M53020</link>
      <description>&lt;P&gt;I don't know about truncating the first three, but OrderBy should allow you to at least list them in descending order. I think you would do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var dist = Top(OrderBy(Distance(s, $feature, 'miles'), 'miles DESC'),3)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, I'm not an Arcade expert.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt; Maybe that goes around Push(Top(Orderby(stafflist....) instead of the Distance function.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/developers-questions/how-to-use-arcade-groupby-with-top-and-orderby/m-p/1060406#M5875" target="_blank" rel="noopener"&gt;Solved: Re: How to Use Arcade GroupBy with Top and OrderBy... - Esri Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 17:10:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1302123#M53020</guid>
      <dc:creator>Teresa_Blader</dc:creator>
      <dc:date>2023-06-22T17:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade sorting text help - popup</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1302128#M53023</link>
      <description>&lt;P&gt;Still erroring saying invalid parameter &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Maybe because 'miles' isn't a field already? idk&lt;/P&gt;&lt;P&gt;Thanks for the reply though!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 17:18:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1302128#M53023</guid>
      <dc:creator>HarrisonBrown7</dc:creator>
      <dc:date>2023-06-22T17:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade sorting text help - popup</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1302295#M53032</link>
      <description>&lt;P&gt;I would use a top and order by on the intersects&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#top" target="_blank"&gt;https://developers.arcgis.com/arcade/function-reference/featureset_functions/#top&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 23:48:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1302295#M53032</guid>
      <dc:creator>PeterMilenkovic</dc:creator>
      <dc:date>2023-06-22T23:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade sorting text help - popup</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1302431#M53038</link>
      <description>&lt;P&gt;That didn't work either. My problem is that the feature set I'm wanting to sort only has a name field, and I can't get OrderBy to recognize conditional data from an arcade expression.&lt;/P&gt;&lt;P&gt;Thanks for the suggestion!&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 13:26:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1302431#M53038</guid>
      <dc:creator>HarrisonBrown7</dc:creator>
      <dc:date>2023-06-23T13:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade sorting text help - popup</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1302801#M53060</link>
      <description>&lt;P&gt;Sorry I miss read your question. I would probably create an empty featureset and populate it in your loop, then you can sort it and get the top 3.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var New_FS = {fields:[        
        {'name':'StaffLocation','type': 'esriFieldTypeString'},
        {'name':'SLDistance','type': 'esriFieldTypeDouble'}],
        'geometryType': '',
        'features':[]
        }
    
for (var s in staff){
    var dist = Distance(s,$feature,'miles')
    var new_f = {'attributes': {'StaffLocation': s['Location'] ,
                                'SLDistance': dist}
                 }
    Push(New_FS.features, new_f)}


&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You would then have to loop through this new fs to construct the string for the popup&lt;/P&gt;</description>
      <pubDate>Sun, 25 Jun 2023 22:55:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1302801#M53060</guid>
      <dc:creator>PeterMilenkovic</dc:creator>
      <dc:date>2023-06-25T22:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade sorting text help - popup</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1302993#M53066</link>
      <description>&lt;P&gt;This feels closer to what I'm trying to do, but now I can't get the sort to work. Am I doing something wrong?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// create 250mi buffer on selection
var buff = Buffer($feature, 250, 'miles')

// get intersecting staff locations
var staff = Intersects(buff, FeatureSetByName($map, "CS Staff Locations"))

// create empty featureset to hold results
var New_FS = {fields:[        
        {'name':'StaffLocation','type': 'esriFieldTypeString'},
        {'name':'SLDistance','type': 'esriFieldTypeDouble'}],
        'geometryType': '',
        'features':[]
        }
 
for (var s in staff){
    var dist = Distance(s,$feature,'miles')
    var new_f = {'attributes': {'StaffLocation': s['Location'] ,
                                'SLDistance': dist}
                 }
    Push(New_FS.features, new_f)}

var sorted= Top(OrderBy(New_FS, 'SLDistance ASC'),3)

return sorted&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 14:10:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1302993#M53066</guid>
      <dc:creator>HarrisonBrown7</dc:creator>
      <dc:date>2023-06-26T14:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade sorting text help - popup</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1303199#M53089</link>
      <description>&lt;P&gt;Sorry, forgot to mention you need to convert the populated dictionary/featureset to read like one.&lt;/P&gt;&lt;P&gt;Try&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var sorted = Top(OrderBy(FeatureSet(Text(New_FS)), 'SLDistance ASC'),3)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 22:32:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1303199#M53089</guid>
      <dc:creator>PeterMilenkovic</dc:creator>
      <dc:date>2023-06-26T22:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade sorting text help - popup</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1303370#M53097</link>
      <description>&lt;P&gt;This is fantastic, thank you so much!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2023 13:37:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-sorting-text-help-popup/m-p/1303370#M53097</guid>
      <dc:creator>HarrisonBrown7</dc:creator>
      <dc:date>2023-06-27T13:37:39Z</dc:date>
    </item>
  </channel>
</rss>

