Java List Sort sort(List list, Comparator comparator)

Here you can find the source of sort(List list, Comparator comparator)

Description

Same as in java.util.Collections, but returns list to allow daisy chaining calls

License

Apache License

Declaration

public static <T> List<T> sort(List<T> list, Comparator<T> comparator) 

Method Source Code

//package com.java2s;
/*/*w  w  w.j av  a  2 s  .c  om*/
 *  Copyright Gergely Nagy <greg@webhejj.hu>
 *
 *  Licensed under the Apache License, Version 2.0; 
 *  you may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 */

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

public class Main {
    /**
     * Same as in java.util.Collections, but returns list to allow daisy chaining calls
     */
    public static <T extends Comparable<? super T>> List<T> sort(List<T> list) {
        Collections.sort(list);
        return list;
    }

    /**
     * Same as in java.util.Collections, but returns list to allow daisy chaining calls
     */
    public static <T> List<T> sort(List<T> list, Comparator<T> comparator) {
        Collections.sort(list, comparator);
        return list;
    }
}

Related

  1. sort(List list)
  2. sort(List list)
  3. sort(List list)
  4. sort(List list, Comparator c)
  5. sort(List list, Comparator comparator)
  6. sort(List list, Comparator comparator, String sort, boolean sortOrder)
  7. sort(List objs, Comparator cp)
  8. sort(Set list, Comparator comparator)
  9. sort(String prefix, int[] a, List list)