Here you can find the source of sortList(List
public static <T extends Comparable<T>> List<T> sortList(List<T> list, boolean asc)
//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; } }