Java List Sort sort(List source)

Here you can find the source of sort(List source)

Description

sort

License

Open Source License

Declaration

@SuppressWarnings("rawtypes")
    public static <E extends Enum> List<E> sort(List<E> source) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2008 flowr.org - all rights reserved. This program and the accompanying materials are made available
 * under the terms of the Eclipse Public License (EPL) v1.0. The EPL is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * Contributors: flowr.org - initial API and implementation
 ******************************************************************************/

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

import java.util.List;

public class Main {
    @SuppressWarnings("rawtypes")
    public static <E extends Enum> List<E> sort(List<E> source) {
        Collections.sort(source, new Comparator<E>() {

            @Override/*w  w  w.  j av  a  2 s .  c  o m*/
            public int compare(E o1, E o2) {
                return o1.ordinal() - o2.ordinal();
            }
        });
        return source;
    }
}

Related

  1. sort(List list)
  2. sort(List list)
  3. sort(List list, Comparator comparator)
  4. sort(List list1, List list2)
  5. sort(List list)
  6. sort(List> listOfClassDataList)
  7. sort(List> lists)
  8. sort(List lists)
  9. sort(List list)