How can I sort this array of CDT?

Hi,

I have an array of     CDT ABC:

{

{  Id: 111111, position: L1}

{  Id: 22222, position: R2}

{  Id: 333, position: L2}

{  Id: 44, position: R1}

{  Id: 555, position: L3}

{  Id: 666, position: R3}

}

 

Now I need to sort this array as

{

{  Id: 111111, position: L1}

{  Id: 333, position: L2}

{  Id: 555, position: L3}

{  Id: 44, position: R1}

{  Id: 22222, position: R2}

{  Id: 666, position: R3}

}

Can someone give me some hint?

Thanks,

Peiran

 

  Discussion posts and replies are publicly visible

Parents Reply
  • Ah yes, todatasubset() will work for this scenario as well since the desired sort is in fact in alphabetical order!

    a!localVariables(
      local!cdt: {
        {  Id: 111111, position: "L1"},
        {  Id: 22222, position: "R2"},
        {  Id: 333, position: "L2"},
        {  Id: 44, position: "R1"},
        {  Id: 555, position: "L3"},
        {  Id: 666, position: "R3"}
      },
    
      todatasubset(
        local!cdt,
        a!pagingInfo(1,-1,a!sortInfo("position",true))
      ).data
    )

Children