Here you can find the source of sort(Collection
public static <T extends Comparable<? super T>> List<T> sort(Collection<T> list)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.List; public class Main { public static <T extends Comparable<? super T>> List<T> sort(Collection<T> list) { List<T> list1 = new ArrayList<>(list); Collections.sort(list1);/*from ww w .jav a 2 s. co m*/ return list1; } public static <T> List<T> sort(Collection<T> list, Comparator<? super T> comparator) { List<T> list1 = new ArrayList<>(list); Collections.sort(list1, comparator); return list1; } }