public int compare(Object o1, Object o2) { NullableTuple nt1 = (NullableTuple) o1; NullableTuple nt2 = (NullableTuple) o2; int rc = 0; // If either are null, handle differently. if (!nt1.isNull() && !nt2.isNull()) { rc = compareTuple((Tuple) nt1.getValueAsPigType(), (Tuple) nt2.getValueAsPigType()); } else { // For sorting purposes two nulls are equal. if (nt1.isNull() && nt2.isNull()) rc = 0; else if (nt1.isNull()) rc = -1; else rc = 1; if (mWholeTuple && !mAsc[0]) rc *= -1; } return rc; }