using System.Collections;
using System.Collections.Generic;
public static void Main()
var x = new MyClass(new List<MySub> { new(id) });
var y = new MyClass(new List<MySub> { new(id) });
var comparer = new ObjectsComparer.Comparer<MyClass>();
Console.WriteLine(comparer.Compare(x, y));
public record MyClass(IReadOnlyCollection<MySub> Subs) : IComparable<MyClass>
public int CompareTo(MyClass other)
if (ReferenceEquals(this, other))
if (ReferenceEquals(null, other))
return Subs.First().Id.CompareTo(other.Subs.First().Id);
public record MySub(Guid Id);