Here you can find the source of toSortedList(Collection
public static <T extends Comparable<? super T>> List<T> toSortedList(Collection<T> collection)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static <T extends Comparable<? super T>> List<T> toSortedList(Collection<T> collection) { List<T> list = new LinkedList<>(collection); Collections.sort(list);/*w ww . j a va 2 s . c o m*/ return list; } }