Skip to main content
June 12, 2023
Question

Function

  • June 12, 2023
  • 9 replies
  • 0 views

What Is a function for showing array itoem in ascending or descending

    9 replies

    harshitb6843
    June 12, 2023

    There is no direct function. You can use todatasubset() paired with sortInfo() to get the desired result.

    a!localVariables(
      local!array: a!forEach(
        items: ri!array,
        expression: { utls: fv!item }
      ),
      todatasubset(
        arrayToPage: local!array,
        pagingConfiguration: a!pagingInfo(
          startIndex: 1,
          batchSize: - 1,
          sort: a!sortInfo(field: "utls", ascending: ri!isAscending)
        )
      ).data.utls
    )

    mathieud0001
    Brainy
    June 12, 2023

    This is the best way.

    June 12, 2023

    You can also use Sort Utilities plugin, only if you are okay with dependency on a custom plugin.

    However, I believe it is high time Appian should introduce OOTB documented version of the hidden sort() function, instead of forcing us to first convert the data into key value pairs and then use todatasubset and pagingInfo just to apply sorting to a list of numbers.

    Hidden sort() function:

    harshitb6843
    June 12, 2023

    I hope you know you shouldn't be using undocumented functions. 

    June 12, 2023

    Yupp! I know that pretty well. Just one of many requests which we have from Appian.