mavenversioncmp.py
def compare (a, b):
  """
  Compares two versions using the following rules:

  - numerical comparison of major version
  - numerical comparison of minor version
  - if revision does not exist, add ".0" for comparison purposes
  - numerical comparison of revision
  - if qualifier does not exist, it is newer than if it does
  - case-insensitive string comparison of qualifier
  - this ensures timestamps are correctly ordered, and SNAPSHOT is newer than an equivalent timestamp
  - this also ensures that beta comes after alpha, as does rc
  - if no qualifier, and build does not exist, add "-0" for comparison purposes
  - numerical comparison of build  
  """
  (aMajor, aMinor, aRevision, aQualifier, aBuild) = getCanonical(a)
  (bMajor, bMinor, bRevision, bQualifier, bBuild) = getCanonical(b)

  if (aMajor < bMajor):
    return -1

  elif (aMajor == bMajor):
    if (aMinor < bMinor):
      return -1

    elif (aMinor == bMinor):
      if (aRevision < bRevision):
        return -1

      elif (aRevision == bRevision):
        if (
          ((aQualifier == '') and (bQualifier != ''))
          or (aQualifier < bQualifier)
        ):
          return -1

        elif (aQualifier == bQualifier):
          if (aBuild < bBuild):
            return -1

          elif (aBuild == bBuild):
            return 0

  # if not equal and not lower, then it is bigger :D
  return 1

  Compares two versions using the following rules:

  - numerical comparison of major version
  - numerical comparison of minor version
  - if revision does not exist, add ".0" for comparison purposes
  - numerical comparison of revision
  - if qualifier does not exist, it is newer than if it does
  - case-insensitive string comparison of qualifier
  - this ensures timestamps are correctly ordered, and SNAPSHOT is newer than an equivalent timestamp
  - this also ensures that beta comes after alpha, as does rc
  - if no qualifier, and build does not exist, add "-0" for comparison purposes
  - numerical comparison of build  
  
Compares two versions using the following rules:
numerical comparison of major version
numerical comparison of minor version
if revision does not exist, add ".0" for comparison purposes
numerical comparison of revision
if qualifier does not exist, it is newer than if it does
case-insensitive string comparison of qualifier
this ensures timestamps are correctly ordered, and SNAPSHOT is newer than an equivalent timestamp
this also ensures that beta comes after alpha, as does rc
if no qualifier, and build does not exist, add "-0" for comparison purposes
numerical comparison of build
Compares two versions using the following rules : numerical comparison of major version numerical comparison of minor version if revision does not exist add " . 0 " for comparison purposes numerical comparison of revision if qualifier does not exist it is newer than if it does case - insensitive string comparison of qualifier this ensures timestamps are correctly ordered and SNAPSHOT is newer than an equivalent timestamp this also ensures that beta comes after alpha as does rc if no qualifier and build does not exist add " - 0 " for comparison purposes numerical comparison of build
def compare (a, b):
  (aMajor, aMinor, aRevision, aQualifier, aBuild) = getCanonical(a)
  (bMajor, bMinor, bRevision, bQualifier, bBuild) = getCanonical(b)
  if (aMajor < bMajor):
    return -1
  elif (aMajor == bMajor):
    if (aMinor < bMinor):
      return -1
    elif (aMinor == bMinor):
      if (aRevision < bRevision):
        return -1
      elif (aRevision == bRevision):
        if (
          ((aQualifier == '') and (bQualifier != ''))
          or (aQualifier < bQualifier)
        ):
          return -1
        elif (aQualifier == bQualifier):
          if (aBuild < bBuild):
            return -1
          elif (aBuild == bBuild):
            return 0
  return 1
def compare ( a , b ) : ( aMajor , aMinor , aRevision , aQualifier , aBuild ) = getCanonical ( a ) ( bMajor , bMinor , bRevision , bQualifier , bBuild ) = getCanonical ( b ) if ( aMajor < bMajor ) : return - 1 elif ( aMajor == bMajor ) : if ( aMinor < bMinor ) : return - 1 elif ( aMinor == bMinor ) : if ( aRevision < bRevision ) : return - 1 elif ( aRevision == bRevision ) : if ( ( ( aQualifier == '' ) and ( bQualifier != '' ) ) or ( aQualifier < bQualifier ) ) : return - 1 elif ( aQualifier == bQualifier ) : if ( aBuild < bBuild ) : return - 1 elif ( aBuild == bBuild ) : return 0 return 1
Compares two versions using the following rules:
 numerical comparison of major version
 numerical comparison of minor version
 if revision does not exist, add ".0" for comparison purposes
 numerical comparison of revision
 if qualifier does not exist, it is newer than if it does
 case-insensitive string comparison of qualifier
 this ensures timestamps are correctly ordered, and SNAPSHOT is newer than an equivalent timestamp
 this also ensures that beta comes after alpha, as does rc
 if no qualifier, and build does not exist, add "-0" for comparison purposes
 numerical comparison of build
Compares two versions using the following rules : numerical comparison of major version numerical comparison of minor version if revision does not exist add " . 0 " for comparison purposes numerical comparison of revision if qualifier does not exist it is newer than if it does case - insensitive string comparison of qualifier this ensures timestamps are correctly ordered and SNAPSHOT is newer than an equivalent timestamp this also ensures that beta comes after alpha as does rc if no qualifier and build does not exist add " - 0 " for comparison purposes numerical comparison of build
"""
  Compares two versions using the following rules:

  - numerical comparison of major version
  - numerical comparison of minor version
  - if revision does not exist, add ".0" for comparison purposes
  - numerical comparison of revision
  - if qualifier does not exist, it is newer than if it does
  - case-insensitive string comparison of qualifier
  - this ensures timestamps are correctly ordered, and SNAPSHOT is newer than an equivalent timestamp
  - this also ensures that beta comes after alpha, as does rc
  - if no qualifier, and build does not exist, add "-0" for comparison purposes
  - numerical comparison of build  
  """ # if not equal and not lower, then it is bigger :D
a
b