Skip to main content
October 10, 2023
Solved

How to sort an array based on a field in one CDT that is nested in another CDT

  • October 10, 2023
  • 1 reply
  • 0 views

Hi everyone, 

I'm having a CDT (CDT01) with fields: {id: int, name: text, information: {id: int,fieldId: int,address: text}}

As you can see, the information field contains a different CDT (CDT02) that is nested inside CDT01. 

I would like to sort a list of CDT01 based on CDT02.fieldId. Is there any solution for that? I tried toDataSubset and dataSubset but seems like I can only index the first layer of the CDT. 

Thanks for helping :)

    Best answer by linhn

    I just found the answer myself! Found out it can be achieved simply by "information.fieldId" in sortInfo field within dataSubset or toDataSubset

    1 reply

    linhnAuthorAnswer
    October 10, 2023

    I just found the answer myself! Found out it can be achieved simply by "information.fieldId" in sortInfo field within dataSubset or toDataSubset