Appian Community and Appian Academy are being upgraded. As a part of the upgrade, Appian Community is currently in read-only mode, and user registration is disabled until August 3. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!
The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.
Hi,
We have a datetime field array and want to sort it in ascending order. Please let me know how to do it. If you have any code snippet please share which will be helpful.
Thanks in advance.
Discussion posts and replies are publicly visible
From where are we getting the data. If it is from the database, we can apply sorting with paging. Else, we can try converting the data to the data subset and then apply sorting.
As 'yoga' mentioned...if the data is in a database you'd be better off using the SQL's 'ORDER BY' to apply the sort before retrieving into Appian.
In Appian you can use the 'sort' capability of a datasubset, something like this:
load( local!dataToSort: a!forEach( items: ri!dateTime, expression: {item: fv!item} ), fn!todatasubset( local!dataToSort, a!pagingInfo( startIndex: 1, batchSize: -1, sort: a!sortInfo( field: "item", ascending: true ) ) ).data.item )
Utilize the "ORDER BY" is you want to sort at database layer itself
or convert it into a datasubset to use a!sortInfo() function on your datetime field
I had an array of time values that I needed to appear in ascending order.
This worked for me:
local!timingChoices: sort(index(local!sourseList, "timing_val", null))
sort is a hidden function, it does the trick, but shouldn't be used for serious stuff.