private IEnumerable <Variable> SortVariables(Summand summand) { return(summand.Variables .OrderBy(var => var.Name) .ThenBy(var => var.Degree) .ToList()); }
public bool IsSimilarTo(Summand summand) { if (summand == null) { return(false); } if (Variables == null || summand.Variables == null) { return(false); } if (Variables.Length != summand.Variables.Length) { return(false); } var sortedFirstVariables = SortVariables(this); var sortedSecondVariables = SortVariables(summand); return(sortedFirstVariables.SequenceEqual(sortedSecondVariables)); }