Java Utililty Methods List Sort

List of utility methods to do List Sort

Description

The list of methods to do List Sort are organized into topic(s).

Method

voidsort(List list)
sort
if (comparator == null) {
    comparator = new Comparator() {
        public int compare(Object o1, Object o2) {
            return o1.toString().compareToIgnoreCase(o2.toString());
    };
Collections.sort(list, comparator);
...
voidsort(List list, Comparator comparator)
Sorts a list, if it exists.
if (list == null || list.isEmpty()) {
    return;
Collections.sort(list, comparator);
intsort(List list1, List list2)
sort
return list2.size() - list1.size();
Listsort(List list)
sort
return sort(list, null);
Listsort(List source)
sort
Collections.sort(source, new Comparator<E>() {
    @Override
    public int compare(E o1, E o2) {
        return o1.ordinal() - o2.ordinal();
});
return source;
voidsort(List> listOfClassDataList)
Sort outer list by using first element of inner list
Collections.sort(listOfClassDataList, new Comparator<List<T>>() {
    @Override
    public int compare(List<T> o1, List<T> o2) {
        if (o1 == null && o2 == null) {
            return 0;
        if (o1 == null && o2 != null) {
            return -1;
...
voidsort(List> lists)
sort
Map<String, List<T>> map = new TreeMap<String, List<T>>();
for (List<T> list : lists) {
    Collections.sort(list);
    StringBuilder builder = new StringBuilder();
    for (T item : list) {
        builder.append(item.toString());
    map.put(builder.toString(), list);
...
Listsort(List lists)
sort
Collections.sort(lists);
return lists;
voidsort(List list)
sort
Listsort(List list)
sort
if (list != null && list.size() > 0) {
    Collections.sort((List) list);
return list;