@Override
 public int compare(WritableComparable w1, WritableComparable w2) {
   IntPair ip1 = (IntPair) w1;
   IntPair ip2 = (IntPair) w2;
   int cmp = IntPair.compare(ip1.getFirst(), ip2.getFirst());
   if (cmp != 0) {
     return cmp;
   }
   return -IntPair.compare(ip1.getSecond(), ip2.getSecond()); // reverse
 }
 @Override
 public int compare(WritableComparable w1, WritableComparable w2) {
   IntPair ip1 = (IntPair) w1;
   IntPair ip2 = (IntPair) w2;
   return IntPair.compare(ip1.getFirst(), ip2.getFirst());
 }
 @Override
 public int getPartition(IntPair key, NullWritable value, int numPartitions) {
   return Math.abs(key.getFirst() * 127) % numPartitions;
 }