Here you can find the source of sorted(Iterable
public static <T> Iterable<T> sorted(Iterable<T> input)
//package com.java2s; //License from project: Open Source License import java.util.TreeSet; public class Main { public static <T> Iterable<T> sorted(Iterable<T> input) { TreeSet<T> ret = new TreeSet<T>(); for (T t : input) { ret.add(t);/* w ww. j a v a 2s .c o m*/ } return ret; } }