Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. 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.
Do we have any function to sort an array of type integers in Ascending or Descending order (except a!sortInfo(), which did not help)?
For instance: I have an Array {1, 4, 6, 8, 5, 3} & I want to sort it in Ascending. So the O/P will be {1, 3, 4, 5, 6, 8}
Thanks in advance!
Discussion posts and replies are publicly visible
There's no (supported) sort function that we can use outside of the example I'm going to show you (I say "unsupported" because there *is* a function that exists but is flagged by Appian as being unsupported).
a!sortInfo() is a system type that holds the instructions for how a sort operation should be applied. You need to use this within a datasubset. Here's how:
a!localVariables( local!array: { 1, 4, 6, 8, 5, 3 }, local!fieldArray: a!forEach( items: local!array, expression: a!map(id: fv!item) ), local!datasubset: fn!todatasubset( arrayToPage: local!fieldArray, pagingConfiguration: a!pagingInfo( startIndex: 1, batchSize: - 1, sort: a!sortInfo(field: "id", ascending: true) ) ), local!datasubset.data.id )
Yes it's ugly and long-winded but it does the job.
Take a look at 'Sort Utilities' plugin.
An Alternative solution
What is the difference?
Why can't we go like this for sorting in ascending or descending order?
Because sort() is not part of the public API.
Thanks Stefan Helzle , for the clarification