You can write your own implementation of IEqualityComparer<List<int>> . For GetHashCode() it will simply return the XOR of all the hash codes of the items in the list. For Equals() it will create a new HashSet<int> from the first list and call HashSet<T>.SetEquals , moving to the second list. This suggests that there will be no duplicate elements, mind you. (Otherwise, {1, 1, 2} will be equal to {1, 2, 2}, but has a different hash code.)
Once you have come this far, you can use Distinct :
var distinct = list.Distinct(new CustomEqualityComparer());
As an alternative approach, could you use HashSet<T> as the type of your collection to start with? Then it is really easy:
var distinct = sets.Distinct(HashSet<int>.CreateSetComparer());
If you need lists as input, but they can handle the sets:
var distinct = list.Select(x => new HashSet<int>(x)) .Distinct(HashSet<int>.CreateSetComparer());
Jon skeet
source share