An efficient algorithm to cluster a list of tuples : I would like to develop an efficient algorithm which will cluster a list of tuples, as presented below:

    public class Tuple<T, R> {

      private final T left;
      private final R right;

      public Tuple(T left, R right) {
          this.left = left;
          this.right = right;
      }

      public T getLeft() {
          return left;
      }

      public R getRight() {
          return right;
      }
    }

And return them grouped, based on equality of 'left' fields or 'right' fields. An output can be a list of groups as specified below:

    public class Group<L, R> extends Tuple<List<L>, List<R>> {

      public Group(List<L> left, List<R> right) {
        super(left, right);
      }
    }  

How can I do this efficiently? Is there a way to parallelise such algorithm using some intermediate concurrent data structures?

Example input: Tuple(4,C),Tuple(1,A),Tuple(2,B),Tuple(3,B),Tuple(3,A), Tuple(5,C), Tuple(6,D) 
Expected output: Group((1,2,3),(A,B)), Group((4,5),(C)), Group((6),(D))

Many thanks for help in advance. Any pseudo code will be appreciated.