parameters: (version1, version2)
return_statement: return 0
docstring: Compare two version strings.
  
      Return
        < 0 if version1 is less than version2
        > 0 if version2 is less than version1
        0 if version1 == version2
docstring_summary: Compare two version strings.
docstring_tokens: Compare two version strings .
function: def compareVersions(version1, version2):
      """
      Compare two version strings.
  
      Return
        < 0 if version1 is less than version2
        > 0 if version2 is less than version1
        0 if version1 == version2
      """
  
      def versionToIntArray(version) :
          return [int(i) for i in version.split('.')]
  
      # parse version components
      version1Nums = versionToIntArray(version1)
      version2Nums = versionToIntArray(version2)
  
      # pad versions to be the same length:
      maxlen = max(len(version1Nums), len(version2Nums))
      while len(version1Nums) < maxlen : version1Nums.append(0)
      while len(version2Nums) < maxlen : version2Nums.append(0)
  
      # compare
      for v1,v2 in zip(version1Nums, version2Nums) :
          if v1 < v2 : return -1
          if v1 > v2 : return 1
  
      return 0
function_tokens: def compareVersions ( version1 , version2 ) : def versionToIntArray ( version ) : return [ int ( i ) for i in version . split ( '.' ) ] # parse version components version1Nums = versionToIntArray ( version1 ) version2Nums = versionToIntArray ( version2 ) # pad versions to be the same length: maxlen = max ( len ( version1Nums ) , len ( version2Nums ) ) while len ( version1Nums ) < maxlen : version1Nums . append ( 0 ) while len ( version2Nums ) < maxlen : version2Nums . append ( 0 ) # compare for v1 , v2 in zip ( version1Nums , version2Nums ) : if v1 < v2 : return - 1 if v1 > v2 : return 1 return 0