Here you can find the source of sort(List list, Comparator comparator)
public static void sort(List list, Comparator comparator)
//package com.java2s; /**/* w w w .j av a 2 s .co m*/ * Copyright (c) 2016-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ import java.util.Collections; import java.util.Comparator; import java.util.List; public class Main { /** * Sorts a list, if it exists. Otherwise just returns. */ public static void sort(List list, Comparator comparator) { if (list == null || list.isEmpty()) { return; } Collections.sort(list, comparator); } }