public int CompareTo(LatLngPoint other) { if (other is null) { return(-1); } else { var byLat = Latitude.CompareTo(other.Latitude); var byLng = Longitude.CompareTo(other.Longitude); var byAlt = Altitude.CompareTo(other.Altitude); if (byLat == 0 && byLng == 0) { return(byAlt); } else if (byLat == 0) { return(byLng); } else { return(byLat); } } }