Skip to content

Instantly share code, notes, and snippets.

@zeljic
Created November 29, 2016 18:39
Show Gist options
  • Select an option

  • Save zeljic/a224fa4f6e1199658eb89f6336740e89 to your computer and use it in GitHub Desktop.

Select an option

Save zeljic/a224fa4f6e1199658eb89f6336740e89 to your computer and use it in GitHub Desktop.

Revisions

  1. zeljic created this gist Nov 29, 2016.
    21 changes: 21 additions & 0 deletions compare.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    private int compare(String vx, String vy)
    {
    String[] vxL = vx.split("\\.");
    String[] vyL = vy.split("\\.");

    final int xSize = vxL.length, ySize = vyL.length, size = Math.max(xSize, ySize);

    Integer iVx, iVy;
    int i, diff;

    for (i = 0; i < size; i++)
    {
    iVx = i == xSize ? 0 : Integer.valueOf(vxL[i]);
    iVy = i == ySize ? 0 : Integer.valueOf(vyL[i]);

    if ((diff = iVx.compareTo(iVy)) != 0)
    return diff;
    }

    return 0;
    }