Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Collections;

import java.util.List;

public class Main {
    /**
     * Convenience method for sorting a list by either ascending or descending
     * Ascending is exactly the same as calling Collections.sort(list)
     * Descending is exactly the same as calling Collections.sort(list, Collections.reverseOrder())
     * 
     * @param list
     * @param isAscending
     */
    public static <T extends Comparable<? super T>> void sort(List<T> list, boolean isAscending) {
        if (isAscending) {
            Collections.sort(list);
        } else { //is dec
            Collections.sort(list, Collections.reverseOrder());
        }
    }
}