Here you can find the source of sort(Collection
public static <T> List<T> sort(Collection<T> collection, Comparator<T> comparator)
//package com.java2s; //License from project: Apache 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> List<T> sort(Collection<T> collection, Comparator<T> comparator) { List<T> list = new ArrayList<T>(collection); Collections.sort(list, comparator); return list; }//w ww . j av a 2 s . co m }