code: public static Comparator<LongTuple> byDistanceComparator(
          LongTuple reference,
          final ToDoubleBiFunction<? super LongTuple, ? super LongTuple> 
              distanceFunction)
      {
          final LongTuple fReference = LongTuples.copy(reference);
          return new Comparator<LongTuple>()
          {
              @Override
              public int compare(LongTuple t0, LongTuple t1)
              {
                  double d0 = distanceFunction.applyAsDouble(fReference, t0);
                  double d1 = distanceFunction.applyAsDouble(fReference, t1);
                  return Double.compare(d0, d1);
              }
          };
      }
docs: Returns a new comparator that compares {@link LongTuple} instances
  by their distance to the given reference, according to the given
  distance function.
  A copy of the given reference point will be stored, so that changes
  in the given point will not affect the returned comparator.
  
  @param reference The reference point
  @param distanceFunction The distance function
  @return The comparator