Efficient Way: Grouping Arrays (Model Instance)

Hi there,

I have a Model with those attributes:

0 := user_id

1 := partner_id





Array

(

[0] =Array

(

[0] =7

[1] =2

)


[1] =Array

(

[0] =19

[1] =2


)


[2] =Array

(

[0] =13

[1] =3


)


)




Based on that Instance, I want to get two arrays grouped by the partner_id




#1. Array

Array

(

[0] =Array

(

[0] =7

[1] =2

)


[1] =Array

(

[0] =19

[1] =2


)

)





#2. Array

Array

(

[2] =Array

(

[0] =13

[1] =3


)


)




What the best and efficient way to achieve that?

Best regards,

peili

you can extract the data order by partner id, then reorder the arrays.

Another option is to do a query for each partner id, but is less efficient

CMap.mergeArray

array_merge_recursive

array_merge

and this topic/post could be helpful.