code: public static <T> Collection<T> intersect(Collection<T> left, Collection<T> right, Comparator<T> comparator) {
          if (left.isEmpty() || right.isEmpty())
              return createSimilarCollection(left, 0);
  
          Collection<T> result = createSimilarCollection(left, Math.min(left.size(), right.size()));
          //creates the collection to look for values.
          Collection<T> pickFrom = new TreeSet<T>(comparator);
          pickFrom.addAll(left);
  
          for (final T t : right) {
              if (pickFrom.contains(t))
                  result.add(t);
          }
          return result;
      }
docs: Create a Collection composed of the intersection of both collections.  Any
  elements that exist in both collections are added to the resultant collection.
  For collections of custom objects; the objects should implement java.lang.Comparable
  <pre class="groovyTestCase">
  assert [3,4] == [1,2,3,4].intersect([3,4,5,6], Comparator.naturalOrder())
  </pre>
  <pre class="groovyTestCase">
  def one = ['a', 'B', 'c', 'd']
  def two = ['b', 'C', 'd', 'e']
  def compareIgnoreCase = { a, b {@code ->} a.toLowerCase() {@code <=>} b.toLowerCase() }
  assert one.intersect(two) == ['d']
  assert two.intersect(one) == ['d']
  assert one.intersect(two, compareIgnoreCase) == ['b', 'C', 'd']
  assert two.intersect(one, compareIgnoreCase) == ['B', 'c', 'd']
  </pre>
  
  @param left  a Collection
  @param right a Collection
  @param comparator a Comparator
  @return a Collection as an intersection of both collections
  @since 2.5.0