Java List Sort sortList(List list, boolean asc)

Here you can find the source of sortList(List list, boolean asc)

Description

sort List

License

Apache License

Declaration

public static <T extends Comparable<T>> List<T> sortList(List<T> list, boolean asc) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {

    public static <T extends Comparable<T>> List<T> sortList(List<T> list, boolean asc) {
        if (list == null) {
            return list;
        }/*  w ww. j a v  a  2 s.  c om*/
        list.sort((T a, T b) -> {
            if (asc) {
                return a.compareTo(b);
            } else {
                return b.compareTo(a);
            }
        });
        return list;
    }
}

Related

  1. sortList(ArrayList list)
  2. sortList(Collection list)
  3. sortList(java.util.List types)
  4. sortList(List list)
  5. sortList(List items)
  6. sortListAlphabetically(List list)
  7. sortListByMapKey(List> list)
  8. sortListEntry(List firstList, List secondList)
  9. sortListOfDoublesAndRemoveDuplicates(List items, double tolerance, double toleranceSmallNumbers)