Java List Sort sort(List list, Comparator comparator)

Here you can find the source of sort(List list, Comparator comparator)

Description

Sorts a list, if it exists.

License

Open Source License

Declaration

public static void sort(List list, Comparator comparator) 

Method Source Code

//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);
    }
}

Related

  1. sort(Collection list)
  2. sort(final List list)
  3. sort(List list)
  4. sort(List list)
  5. sort(List list)
  6. sort(List list1, List list2)
  7. sort(List list)
  8. sort(List source)
  9. sort(List> listOfClassDataList)