Count duplicate List<int> in List<List<int>>.A duplicate is not order-dependent. { 1, 2, 3 } is a duplicate of { 2, 1, 3 }  Looking for speed without getting silly.public static void CountListTest(){    List<List<int>> testData = new List<List<int>>    {            new List<int> { 7, 3, 4 },            new List<int> { 1, 2, 3 },            new List<int> { 2, 1, 3 },            new List<int> { 6, 8, 3 },            new List<int> { 9, 2, 4 },            new List<int> { 6, 3, 8 },            new List<int> { 7, 3, 4 },    };    List<List<int>> countList = CountList(testData);    Debug.WriteLine();    testData = new List<List<int>>    {            new List<int> { 1, 2, 3 },            new List<int> { 2, 1, 3 },            new List<int> { 6, 8, 3 },            new List<int> { 2, 1, 3, 9 },            new List<int> { 6, 8, 3, 9 },            new List<int> { 2, 1, 3, 9 },            new List<int> { 9, 2, 4 },            new List<int> { 6, 3, 8 },            new List<int> { 7, 3, 4 },    };    countList = CountList(testData);}public static List<List<int>> CountList(List<List<int>> input){    List<List<int>> returnListList = new List<List<int>>();    foreach (List<int> list in input)        list.Sort();    HashSet<int> alreadyMatched = new HashSet<int>();    int count = 0;    bool match = true;    int lastEval = 0;    for (int i = 0; i < input.Count - 1; i++)    {        if (alreadyMatched.Contains(i))            continue;        returnListList.Add(input[i]);        count = 1;        lastEval = 0;        for (int j = i+1; j < input.Count; j++)        {            if (alreadyMatched.Contains(j))                continue;            lastEval = j;            if (input[i].Count() != input[j].Count())                continue;            match = true;            for (int k = 0; k < input[i].Count(); k++)            {                if(input[i][k] != input[j][k])                {                    match = false;                    break;                }            }            if(match)            {                count++;                alreadyMatched.Add(j);            }        }        Debug.WriteLine(Count = {0}  List {1}, count, string.Join(, , input[i]));    }    if (count == 1 && lastEval > 0)    {        Debug.WriteLine(Count = {0}  List {1}, 1, string.Join(, , input[lastEval]));        returnListList.Add(input[lastEval]);    }    return returnListList;}
Count duplicate List
c#;.net;collections
It is also possible to solve the problem using LINQ in combination with a custom comparer:// note: the comparer requires the lists to be sortedpublic class Comparer : IEqualityComparer<List<int>>{    public bool Equals(List<int> x, List<int> y)    {        if (x.Count != y.Count)            return false;                   for (int i = 0; i < x.Count; i++)            if (x[i] != y[i]) return false;                 return true;    }    public int GetHashCode(List<int> x) => x.Count;}And the linq query:IEqualityComparer<List<int>> comparer = new Comparer();testData.ForEach(l => l.Sort());var distinctLists = testData    .GroupBy(i => i, comparer)    .Select(group => new { List = group.Key, Count = group.Count() });foreach (var distinctList in distinctLists)    Console.WriteLine($Count: {distinctList.Count}; List: ({string.Join(, , distinctList.List)}));The LINQ solution is more readable and a little bit faster than the manual comparisation. Depending on the actual size of the test set, you can play with the hash function to further improve performance :).