Removing duplicates "ABD" "BAD" "DAB" from the permutation list

I have a fairly large list of strings that contains duplicates in the sense that if I don't care if A, B, C are in the result, but not in the order in which they are. I searched for many other solutions for removing duplicates, but they usually only work for exact values ​​(which I understand, since these elements are not exact single, but more false or redundant results.) I already have a list and did not create it therefore changing the selection is not an option.

+4
source share
1 answer

Just sort the elements inside each element first.

listOfStrings.Select(s => new string(s.OrderBy(c => c))).Distinct().ToList(); 

You understand what I mean - sort characters. I will check the syntax of this instantly.

+10
source

All Articles