Need to sort datetime field array in ascending order

A Score Level 1

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.

Parents
  • 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
    )

Reply
  • 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
    )

Children
No Data

 Discussion posts and replies are publicly visible