<?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: how to sort a featureset? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-sort-a-featureset/m-p/398018#M36672</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I needed to sort by two fields&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Just for information, you could do that in the sort function. (I know you've got the concatenated field)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Oct 2012 07:30:33 GMT</pubDate>
    <dc:creator>__Rich_</dc:creator>
    <dc:date>2012-10-11T07:30:33Z</dc:date>
    <item>
      <title>how to sort a featureset?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-sort-a-featureset/m-p/398014#M36668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Has anyone found or written a function to take a featureSet and sort it based on a specified attribute? The only way I can think of right now would be to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;OL&gt;&lt;BR /&gt;&lt;LI&gt; create a dojo dGrid via code&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt; provide the featureSet as it's store&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt; sort the dGrid based on the appropriate column&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt; create a new featureSet based on the sorted store&lt;/LI&gt;&lt;BR /&gt;&lt;/OL&gt;&lt;SPAN&gt;Thanks-&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2012 14:07:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-sort-a-featureset/m-p/398014#M36668</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2012-10-10T14:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to sort a featureset?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-sort-a-featureset/m-p/398015#M36669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Vanilla JS - &lt;/SPAN&gt;&lt;A href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort"&gt;https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Or if you want to use Dojo, then you could push the items into a store (no need for a UI component e.g. dGrid) and then fetch them back sorted - &lt;/SPAN&gt;&lt;A href="http://dojotoolkit.org/reference-guide/1.7/quickstart/data/usingdatastores/sorting.html#quickstart-data-usingdatastores-sorting"&gt;http://dojotoolkit.org/reference-guide/1.7/quickstart/data/usingdatastores/sorting.html#quickstart-data-usingdatastores-sorting&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Either way, you're going to need to write some code....&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2012 14:30:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-sort-a-featureset/m-p/398015#M36669</guid>
      <dc:creator>__Rich_</dc:creator>
      <dc:date>2012-10-10T14:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to sort a featureset?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-sort-a-featureset/m-p/398016#M36670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You really want to sort on the featureSet.features array.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can pass a function to the sort method to determine your sort.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I use this, but there's probably a better way to do this, since I need a text sort, not numbers or dates.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var _sort = function(field) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return function(a, b) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var x, y; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = a.attributes[field].toLowerCase(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = b.attributes[field].toLowerCase();&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (x &amp;lt; y) ? -1 : 1; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }; };&amp;nbsp; _featureSet.features.sort(_sort('FIELD_NAME'));&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;edit, had wrong file in clipboard&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2012 14:42:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-sort-a-featureset/m-p/398016#M36670</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2012-10-10T14:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to sort a featureset?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-sort-a-featureset/m-p/398017#M36671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Awesome! Thanks. I realized after posting that the datastore was more what I had in mind instead of the datagrid. At first, I thought that Rene's example would &lt;/SPAN&gt;&lt;STRONG style="font-style: italic;"&gt;almost&lt;/STRONG&gt;&lt;SPAN&gt; work for me since I do need to sort based on string values. My only catch is that I needed to sort by two fields (census tract being one and block group the other). As it turns out, there is a another field in my data which is a combination of the two which I had overlooked so Rene's code snippit works! Huzzah!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2012 15:20:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-sort-a-featureset/m-p/398017#M36671</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2012-10-10T15:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to sort a featureset?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-sort-a-featureset/m-p/398018#M36672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I needed to sort by two fields&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Just for information, you could do that in the sort function. (I know you've got the concatenated field)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2012 07:30:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-sort-a-featureset/m-p/398018#M36672</guid>
      <dc:creator>__Rich_</dc:creator>
      <dc:date>2012-10-11T07:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to sort a featureset?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-sort-a-featureset/m-p/398019#M36673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;featureset is basically an array, you can use LinqJS to do everything you want with it&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://linqjs.codeplex.com/"&gt;http://linqjs.codeplex.com/&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2012 08:41:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-sort-a-featureset/m-p/398019#M36673</guid>
      <dc:creator>deleted-user-pYdfRjvSAbTJ</dc:creator>
      <dc:date>2012-10-11T08:41:59Z</dc:date>
    </item>
  </channel>
</rss>

