public static int Compare(BritishPostcode comparand1, BritishPostcode comparand2) { if (ReferenceEquals(comparand1, comparand2)) { return(0); } if (ReferenceEquals(null, comparand1)) { return(-1); } if (ReferenceEquals(null, comparand2)) { return(1); } var comparison = Parts.Comparison(comparand1.Values.Area, comparand2.Values.Area); if (comparison.HasValue) { return(comparison.Value); } comparison = Parts.Comparison(comparand1.Values.DistrictNumber, comparand2.Values.DistrictNumber); if (comparison.HasValue) { return(comparison.Value); } comparison = Parts.Comparison(comparand1.Values.DistrictLetter, comparand2.Values.DistrictLetter); if (comparison.HasValue) { return(comparison.Value); } comparison = Parts.Comparison(comparand1.Values.Sector, comparand2.Values.Sector); if (comparison.HasValue) { return(comparison.Value); } comparison = Parts.Comparison(comparand1.Values.Unit, comparand2.Values.Unit); return(comparison.HasValue ? comparison.Value : 0); }