Sort/Group List by string values

Hi Forum

I am looking to sort/group the list in the GetItemAtIndex list into a sublist by the UniqueItems list - please see attached.

I am hoping to get the following solution:

0
LT-CM-1
LT-CM-2
1
FN-CSB-1
FN-CSB-2
2
SW-BN-1
SW-BN-2

I have tried string.Contains but cannot get my head around the logic to achieve this.
Any help would be greatly appreciated.
Many thanks

If your index is always 1 item long you can do something like this:

Hi Jonathan

Many thanks for this! I was looking at the GroupByKey. Sadly the last value will increase to 2 or more. Any thoughts?

Thank you very much again.

Regards
Tim

Sorry, 2 or more digits at the end I mean.

Hi Jonathan

Using your approach I think I have got it. See attached, using the string length and GroupByKey seems to have done it.

Many thanks again for your help.
Tim

Perhaps this helps?

Hi 3Pinter

This works a treat! Thank you so much. Just followed it below.

Thank you again for everyone’s help.

Cheers
Tim

Hi erfajo

This is brilliant, very nice, thank you.

Thank you for the excellent solutions.
Cheers
Tim

Thanks again erfajo. This looks great - wish I was at Python level, but still at OOTB!

Thanks again
Tim