score:1

Accepted answer

you can group by a string produced from your list items taken in the same order. assuming that '|' character is not allowed inside names, you can do this:

var namelist = json_converted
    .groupby(n => string.join("|", n.names.orderby(s => s)))
    .select(g => new {
        name = g.first().names
    ,   count = g.count()
    });

this approach constructs a string "a|b" from lists ["a", "b"] and ["b", "a"], and use that string for grouping the content.

since the keys are composed of ordered names, g.first().names used as name may not be in the same order for all elements of the group.

score:1

you can write a comparer for the list of names.

public class namescomparer : iequalitycomparer<ienumerable<string>>
{
    public bool equals(ienumerable<string> x, ienumerable<string> y)
    {
        //do your null checks
        return x.sequenceequal(y);
    }

    public int gethashcode(ienumerable<string> obj)
    {
        return 0;
    }
}

then use that in groupby:

var namelist = json_converted.groupby(n => n.names, new namescomparer())
                             .select(i => new { name = i.key, count = i.count() });

Related Query

More Query from same tag