public static int compareVersions(String v1,String v2){
  String[] components1=split(v1);
  String[] components2=split(v2);
  int diff;
  int length=Math.min(components1.length,components2.length);
  for (int i=0; i < length; i++) {
    String s1=components1[i];
    String s2=components2[i];
    Integer i1=tryParseInteger(s1);
    Integer i2=tryParseInteger(s2);
    if (i1 != null && i2 != null) {
      diff=i1.compareTo(i2);
    }
 else {
      diff=s1.compareTo(s2);
    }
    if (diff != 0) {
      return diff;
    }
  }
  diff=Integer.compare(components1.length,components2.length);
  if (diff == 0) {
    diff=Objects.compare(v1,v2);
  }
  return diff;
}

public static int compareVersions ( String v1 , String v2 ) { String [ ] components1 = split ( v1 ) ; String [ ] components2 = split ( v2 ) ; int diff ; int length = Math . min ( components1 . length , components2 . length ) ; for ( int i = 0 ; i < length ; i ++ ) { String s1 = components1 [ i ] ; String s2 = components2 [ i ] ; Integer i1 = tryParseInteger ( s1 ) ; Integer i2 = tryParseInteger ( s2 ) ; if ( i1 != null && i2 != null ) { diff = i1 . compareTo ( i2 ) ; } else { diff = s1 . compareTo ( s2 ) ; } if ( diff != 0 ) { return diff ; } } diff = Integer . compare ( components1 . length , components2 . length ) ; if ( diff == 0 ) { diff = Objects . compare ( v1 , v2 ) ; } return diff ; }
compares two version strings such that " 1 . 10 . 1 " > " 1 . 4 " etc
