static int compare(Comparable<?>[] vectorA, Comparable<?> padA, Comparable<?>[] vectorB, Comparable<?> padB) {
int top = vectorA.length;
if (top > vectorB.length)
top = vectorB.length;
for (int idx = 0; idx < top; ++idx) {
int cmp = compareSegments(vectorA[idx], vectorB[idx]);
if (cmp != 0)
return cmp;
}
if (top < vectorA.length)
return (padB == null) ? 1 : compareReminder(top, vectorA, padA, padB);
if (top < vectorB.length)
return (padA == null) ? -1 : -compareReminder(top, vectorB, padB, padA);
return padA == null ? (padB == null ? 0 : -1) : (padB == null ? 1 : compareSegments(padA, padB));
}