code: def _compare_versions(v1, v2):
      
      def normalize(v):
          # strip trailing .0 or .00 or .0.0 or ...
          v = re.sub(r'(\.0+)*$', '', v)
          result = []
          for part in v.split('.'):
              # just digits
              m = re.match(r'^(\d+)$', part)
              if m:
                  result.append(int(m.group(1)))
                  continue
              # digits letters
              m = re.match(r'^(\d+)([a-zA-Z]+)$', part)
              if m:
                  result.append(int(m.group(1)))
                  result.append(m.group(2))
                  continue
              # digits letters digits
              m = re.match(r'^(\d+)([a-zA-Z]+)(\d+)$', part)
              if m:
                  result.append(int(m.group(1)))
                  result.append(m.group(2))
                  result.append(int(m.group(3)))
                  continue
          return tuple(result)
  
      n1 = normalize(v1)
      n2 = normalize(v2)
  
      return (n1 > n2) - (n1 < n2)
docs: Compare two version strings and return -1, 0 or 1 depending on the equality
      of the subset of matching version numbers.
  
      The implementation is inspired by the top answer at
      http://stackoverflow.com/a/1714190/997768.