Here you can find the source of sorted(Collection extends T> input)
public static <T extends Comparable> List<T> sorted(Collection<? extends T> input)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static <T extends Comparable> List<T> sorted(Collection<? extends T> input) { List<T> sortable = new ArrayList<>(input); Collections.sort(sortable); return sortable; }//from ww w . j a va 2 s . c o m public static <T> List<T> sorted(Collection<? extends T> input, Comparator<T> cmp) { List<T> sortable = new ArrayList<>(input); Collections.sort(sortable, cmp); return sortable; } }