Here you can find the source of sort(List
public static <T> List<T> sort(List<T> list, Comparator<T> comparator)
//package com.java2s; /*/*w w w.j av a 2 s .c om*/ * Copyright Gergely Nagy <greg@webhejj.hu> * * Licensed under the Apache License, Version 2.0; * you may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 */ import java.util.Collections; import java.util.Comparator; import java.util.List; public class Main { /** * Same as in java.util.Collections, but returns list to allow daisy chaining calls */ public static <T extends Comparable<? super T>> List<T> sort(List<T> list) { Collections.sort(list); return list; } /** * Same as in java.util.Collections, but returns list to allow daisy chaining calls */ public static <T> List<T> sort(List<T> list, Comparator<T> comparator) { Collections.sort(list, comparator); return list; } }