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?