<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Sort a CDT array based on a field</title><link>https://community.appian.com/discussions/f/general/10465/sort-a-cdt-array-based-on-a-field</link><description>Hi, 
 I have an array of CDT, which have a string field and an integer field for example. 
 And i want to sort the array of CDT with the field of integer. The integer have repeated numbers. 
 Any suggestion? 
 Thanks</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Sort a CDT array based on a field</title><link>https://community.appian.com/thread/90221?ContentTypeID=1</link><pubDate>Tue, 25 Jan 2022 20:04:54 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:49d2a0c4-03cc-4ec6-9630-d1bc6660bcad</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Yes.&amp;nbsp; When sorting using an &lt;em&gt;a!pagingInfo()&lt;/em&gt; object, an &lt;strong&gt;array&lt;/strong&gt; of &lt;em&gt;&lt;strong&gt;a!sortInfo()&lt;/strong&gt;&lt;/em&gt; objects may be passed in and all of them will be used (in order) to sort the resulting array.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sort a CDT array based on a field</title><link>https://community.appian.com/thread/90220?ContentTypeID=1</link><pubDate>Tue, 25 Jan 2022 19:59:30 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1819cf6b-6339-4bcd-bdc8-a61b58d307b9</guid><dc:creator>linp0001</dc:creator><description>&lt;p&gt;i think I know it now. thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sort a CDT array based on a field</title><link>https://community.appian.com/thread/90217?ContentTypeID=1</link><pubDate>Tue, 25 Jan 2022 19:14:21 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f94c036b-a92c-495f-9318-348a7f48747c</guid><dc:creator>linp0001</dc:creator><description>&lt;p&gt;Hi Josh,&lt;/p&gt;
&lt;p&gt;is it possible to sort on two field in a CDT? just like in SQL, it can set like &amp;quot;ORDER BY Field1 ASC, Field2 ASC&amp;quot;.&lt;/p&gt;
&lt;p&gt;regards,&lt;/p&gt;
&lt;p&gt;Lin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sort a CDT array based on a field</title><link>https://community.appian.com/thread/53492?ContentTypeID=1</link><pubDate>Tue, 20 Mar 2018 12:45:45 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1c57f5d6-43e6-4519-88f6-56c939935235</guid><dc:creator>viveku3486</dc:creator><description>Wow!! This is very helpful. That is why you are one of my favorites here in appian community. Thanks Josh :)&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sort a CDT array based on a field</title><link>https://community.appian.com/thread/45773?ContentTypeID=1</link><pubDate>Fri, 26 May 2017 18:27:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:94fba850-d935-43b6-8064-d18b0bb2c137</guid><dc:creator>Josh</dc:creator><description>&lt;p&gt;The following snippet should help you - local!field would be the field name you want to sort on.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cast(
  typeof(local!cdt),
  todatasubset(
    local!cdt,
    a!pagingInfo(
      startIndex: 1,
      batchSize: -1,
      sort: a!sortInfo(
        field: local!field,
        ascending: local!ascending
      )
    )
  ).data
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>