Java tutorial
//package com.java2s; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; public class Main { /** * Constructs the sorted union of two sets * @param a * @param b * @return the sorted union */ public static <T> SortedSet<T> sortedUnion(Set<T> a, Set<T> b) { SortedSet<T> retVal = new TreeSet<T>(a); retVal.addAll(b); return retVal; } }