public int CompareTo()

in src/BuildScriptGenerator/DotNetCore/SdkVersionInfo.cs [86:132]


        public int CompareTo(SdkVersionInfo other)
        {
            var majorComparison = Major.CompareTo(other.Major);
            if (majorComparison != 0)
            {
                return majorComparison;
            }

            var minorComparison = Minor.CompareTo(other.Minor);
            if (minorComparison != 0)
            {
                return minorComparison;
            }

            var featureComparison = Feature.CompareTo(other.Feature);
            if (featureComparison != 0)
            {
                return featureComparison;
            }

            var patchComparison = Patch.CompareTo(other.Patch);
            if (patchComparison != 0)
            {
                return patchComparison;
            }

            // 3.1.100-preview1-01445 is lesser than 3.1.100
            if (IsPrerelease && !other.IsPrerelease)
            {
                return -1;
            }

            if (!IsPrerelease && other.IsPrerelease)
            {
                return 1;
            }

            if (IsPrerelease && other.IsPrerelease)
            {
                // We are not parsing the preview part here and are only using string comparison
                // One more thing to complicate thing is that the preview part format has changed between
                // 3.* and 5.*, so this comparison is just fine.
                return string.Compare(PrereleaseVersion, other.PrereleaseVersion, ignoreCase: true);
            }

            return 0;
        }