Sorting out duplicates in a list

Hey guys, could you help me?
I can’t wrap my head around this one.
I have a list:
{{“A”,3},{“B”,3},{“C”,2},{“A”,1} };
Every letter has a paired numeric value (e.g. B =3 etc.)
I need to do the following:

  1. find if there are different values for the same letter in the list (e.g. A=1 and also A=3)
  2. compare the values and return mnimum value for that letter (e.g. A=1)
  3. create a new list without duplicates with all letters assigned to minimum values.
    {{“A”,1},{“B”,3},{“C”,2}};

What’s the best way to do it?

Hi @Ilya_Kirichenko

Below are some of the possible ways you can achieve what your looking for. The choice is yours :slight_smile:

Another way:

Find Minimum of Pairs By Unique First Item.dyn (8.0 KB)

Thank You @Kulkul,
I don’t understand the Option 2. In particular the step with “List.FilterByBoolMask”.
The input is a list that contains 2 lists, the mask is a boolean list that contains 6 items, where the first item is true. So basically you just take all the items of the first sublist.

Thank You, @truevis
I get an error: Custom node definition is not loaded! And i can’t edit the custom node. Could you share what’s inside that node?

Here’s a shorter option using “GroupByKey”

1 Like

@Ilya_Kirichenko Another approach
groupAndSort.dyn (4.6 KB)

1 Like

1 Like