def compare_versions(version_a, version_b, zerofill=False):
a_sections = list((int(match) for match in re.findall(r'<STR_LIT>', version_a)))<EOL>b_sections = list((int(match) for match in re.findall(r'<STR_LIT>', version_b)))<EOL>if zerofill:<EOL><INDENT>max_sections = max([len(a_sections), len(b_sections)])<EOL>a_sections += [<NUM_LIT:0> for _ in range(max(max_sections - len(a_sections), <NUM_LIT:0>))]<EOL>b_sections += [<NUM_LIT:0> for _ in range(max(max_sections - len(b_sections), <NUM_LIT:0>))]<EOL><DEDENT>else:<EOL><INDENT>min_sections = min([len(a_sections), len(b_sections)])<EOL>a_sections = a_sections[:min_sections]<EOL>b_sections = b_sections[:min_sections]<EOL><DEDENT>return (b_sections > a_sections) - (b_sections < a_sections)<EOL>
Return direction of version relative to provided version sections

    Args:
        version_a (str): First version to compare
        version_b (str): Second version to compare
        zerofill (bool): If True, treat any missing version sections as 0, otherwise ignore section. Defaults to False

    Returns:
        int: 0 if equal, -1 if a > b, 1 if a < b

    Examples:

        If a is equal to b, return 0
        If a is greater than b, return -1
        If a is less than b, return 1

        >>> compare_versions('2', '2') == 0
        >>> compare_versions('2', '1') == -1
        >>> compare_versions('2', '3') == 1

        If zerofill is False (default), sections not included in both versions are ignored during comparison

        >>> compare_versions('2.13.2', '2.13') == 0
        >>> compare_versions('2.13.2-1234', '3') == 1

        If zerofill is True, any sections in one version not included in other version are set to 0

        >>> compare_versions('2.13.2', '2.13', True) == -1
        >>> compare_versions('2.13.2-1234', '2.13.2', True) == -1
        >>> compare_versions('2.13.2', '2.13.2', True) == 0