Java List Compare sortList(List sources, Comparator comparer)

Here you can find the source of sortList(List sources, Comparator comparer)

Description

sort List

License

Open Source License

Declaration

public static <T> void sortList(List<T> sources, Comparator<? super T> comparer) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;

import java.util.List;

public class Main {

    public static <T> void sortList(List<T> sources, Comparator<? super T> comparer) {
        if (isEmpty(sources) || comparer == null) {
            return;
        }// w w  w  .j  a v a  2 s  . c  o m
        Collections.sort(sources, comparer);
    }

    public static <T extends Comparable<? super T>> void sortList(List<T> sources) {
        if (isEmpty(sources)) {
            return;
        }
        Collections.sort(sources);
    }

    public static boolean isEmpty(Collection<?> entityList) {
        return entityList == null || entityList.isEmpty();
    }
}

Related

  1. compareTo(List list, int i, int j)
  2. compareTwoListOfStrings(List first, List second)
  3. compareVectors(List vectorA, List vectorB)
  4. equalsToAny(Object comparable, Object... compareList)
  5. parseAndCompare(List fileNames, int masterPartitionId)