compare static method

int compare(
  1. List<Coordinate> pts1,
  2. List<Coordinate> pts2
)

Compares two {@link Coordinate} arrays in the forward direction of their coordinates, using lexicographic ordering.

@param pts1 @param pts2 @return an integer indicating the order

Implementation

static int compare(List<Coordinate> pts1, List<Coordinate> pts2) {
  int i = 0;
  while (i < pts1.length && i < pts2.length) {
    int compare = pts1[i].compareTo(pts2[i]);
    if (compare != 0) return compare;
    i++;
  }
  // handle situation when arrays are of different length
  if (i < pts2.length) return -1;
  if (i < pts1.length) return 1;

  return 0;
}