所以我有以下struct
public struct Foo
{
public readonly int FirstLevel;
public readonly int SecondLevel;
public readonly int ThirdLevel;
public readonly int FourthLevel;
}
我在某处执行以下操作
var sequence = new Foo[0];
var orderedSequence = sequence
.OrderBy(foo => foo.FirstLevel)
.ThenBy(foo => foo.SecondLevel)
.ThenBy(foo => foo.ThirdLevel)
.ThenBy(foo => foo.FourthLevel);
现在我想实施System.IComparable<Foo>
例如。的优势.Sort()
。Foo[]
如何将逻辑(从我的特殊/有线OrderBy
/ ThenBy
)转移到int CompareTo(Foo foo)
?