I have a number greater than 10 digit and that stored as a text Is there any way to sort them?

Certified Senior Developer

I have number greater than 10 digit and that stored as a text and  I want sort them. I have tried with sortextarray() that is sorting based on ascii values so it is not giving me correct output. and I tried to convert into int but that is giving me infinity Please help me here to sort the array.

Thanks in advance.

  Discussion posts and replies are publicly visible

Parents
  • If you mean you have a CDT/Dictionary array of data and you want to sort ascending (or descending) on that field then you can use the following code.

    a!localVariables(
      local!numberOfEntries: 10,
      local!data: a!forEach(
        items: 1 + enumerate(local!numberOfEntries),
        expression: {
          id: fv!item,
          number: concat(round(rand(12) * 9, 0))
        }
      ),
      index(
        todatasubset(
          local!data,
          a!pagingInfo(
            startIndex: 1,
            batchSize: -1,
            sort: a!sortInfo(
              field: "number",
              ascending: true
            )
          )
        ),
        "data",
        {}
      )
    )

Reply
  • If you mean you have a CDT/Dictionary array of data and you want to sort ascending (or descending) on that field then you can use the following code.

    a!localVariables(
      local!numberOfEntries: 10,
      local!data: a!forEach(
        items: 1 + enumerate(local!numberOfEntries),
        expression: {
          id: fv!item,
          number: concat(round(rand(12) * 9, 0))
        }
      ),
      index(
        todatasubset(
          local!data,
          a!pagingInfo(
            startIndex: 1,
            batchSize: -1,
            sort: a!sortInfo(
              field: "number",
              ascending: true
            )
          )
        ),
        "data",
        {}
      )
    )

Children