Here you can find the source of sort(List
public static <T> List<T> sort(List<T> objs, Comparator<T> cp)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; public class Main { public static <T> List<T> sort(List<T> objs, Comparator<T> cp) { List<T> new_objs = new ArrayList<T>(); new_objs.addAll(objs); Collections.sort(new_objs, cp); return new_objs; }/*from w w w . ja v a 2 s. com*/ }