Compare nested list and group items based on same values in nested list

Hi all,

I have extracted parameter values by using element.getparameter node. I have nested list. I want tocompare the nested list and group items of same values in the list.

I have 15 parameter values for all the elements. I want to compare it and group the items with same parameter values. If any of the parameter value is empty or blank then similar items at same index with blank values are to be grouped.

Please find the snip below and please let me know how I can tackle this.


Thanks in advance

1 Like

@shashank.baganeACM ,

You can try this way

1 Like

Hi @Draxl_Andreas thanks for your response.

I don’t want like this as snipped

I want to group items at L2 which are having same parameter values.

It is doing something related to L1 values. I dont want to alter the values I want to group the items at L2 with same parameter values without altering their index values.

Hope you got my point. Please let me know how I can proceed.

Can you show a smaller example with the intended outcome you’re after? Your explanation is a little confusing. You say you want to group items with the same value without altering their indices. How would that work? Would you have blank items in the grouped list for values that didn’t match? Do blank values only get grouped if they share the same index?

Hi @Nick_Boyts here it is, I want to groups based on my parameter values within the nested list.
Please find the below snip for your reference.

Those don’t look grouped. What’s wrong with the GroupByKey output you’re showing in the initial post? How do you want them grouped if not like that?

Here it is if I use group by keys.

Actually it is grouping within nested list with unique keys at L1 which I don’t want. I want to group items based on all the 15 parameter values.

Like what I explained above those are the unique items to be considered in the list so based on the parameter values at L2, the items should be grouped under group1, group2, group3, group4 and so on.

in Group1 the parameter values should match for all the grouped elements.
in Group 2 the parameter values should match for all the grouped elements. and so on

I still don’t understand how that’s different from what you’re getting. An example of your expected output would be incredibly helpful.

Are you saying you want a single group for each value in the entire top level list? Not grouped by sublists? If that’s the case then just flatten the list.

1 Like

@Nick_Boyts @Draxl_Andreas Now I think you can get a clear idea for which I am trying to achieve.

This is what I want.

I have all the parameter values but I want to group items or elements based on same parameter values.

I have already extracted element parameter values which is a nested list. From which I want to group elements based on same parameter values.

That’s helpful. Thank you.

Does the order of the “rows” matter or do they just have to have the same values? I would start by sorting the values in each group and then grouping them. You can then count the number of values in each group to know where you have a blank instead of a value.

@Nick_Boyts order should be followed the same. I don’t think I should sort but based on my values I want to group. That too with a nested list. So how do I achieve that ? Do I have any ideas or logics ?

Looking again it seems like each row is determined by size. Wouldn’t it be easier to sort by size then? The problem is the values are out of order in your lists right? How do you know which value goes in which column to be grouped if there are duplicate values within a sublist? It feels like you’re missing information.

Hi @Nick_Boyts @Draxl_Andreas Thanks for your support. I got the solution by myself. I have tried it with List.map using String from Array. Using these as my keys I can group any elements based on keys. PF snip that works for me.

1 Like