in src/PSRule/Runtime/SemanticVersion.cs [400:440]
public int CompareTo(PR pr)
{
if (pr == null || pr.Stable)
return Stable ? 0 : -1;
else if (Stable)
return 1;
var i = -1;
var left = _Identifiers;
var right = pr._Identifiers;
while (++i < left.Length && i < right.Length)
{
var leftNumeric = false;
var rightNumeric = false;
if (long.TryParse(left[i], out var l))
leftNumeric = true;
if (long.TryParse(right[i], out var r))
rightNumeric = true;
if (leftNumeric != rightNumeric)
return leftNumeric ? -1 : 1;
if (leftNumeric && rightNumeric && l == r)
continue;
if (leftNumeric && rightNumeric)
return l.CompareTo(r);
var result = string.Compare(left[i], right[i], StringComparison.Ordinal);
if (result == 0)
continue;
return result;
}
if (left.Length == right.Length)
return 0;
return left.Length > right.Length ? 1 : -1;
}