Here you can find the source of toSortedList(Collection
public static <T extends Comparable<T>> List<T> toSortedList(Collection<T> collection)
//package com.java2s; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; public class Main { public static <T extends Comparable<T>> List<T> toSortedList(Collection<T> collection) { List<T> result = new ArrayList<>(collection); Collections.sort(result); return result; }/* w w w . ja v a 2 s . c o m*/ }