Here you can find the source of getSortedIntersectionValues(Collection
public static <T> Set<T> getSortedIntersectionValues(Collection<T> colection1, Collection<T> colection2)
//package com.java2s; //License from project: LGPL import java.util.Collection; import java.util.HashSet; import java.util.Set; import java.util.TreeSet; public class Main { public static <T> Set<T> getSortedIntersectionValues(Collection<T> colection1, Collection<T> colection2) { Set<T> set = new TreeSet<>(); set.addAll(getIntersectionValues(colection1, colection2)); return set; }/*from www . j av a2 s . co m*/ public static <T> Set<T> getIntersectionValues(Collection<? extends T> colection1, Collection<? extends T> colection2) { Set<T> ret = new HashSet<T>(); if (colection1 == null || colection2 == null) return ret; for (T value : colection1) { if (colection2.contains(value)) ret.add(value); } return ret; } }