Here you can find the source of sort(Collection
Parameter | Description |
---|---|
items | a parameter |
public static <T extends Comparable<? super T>> List<T> sort(Collection<T> items)
//package com.java2s; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.LinkedList; import java.util.List; public class Main { /**/*from w w w. j av a 2 s . co m*/ * Sort the collection and return as list. * * @param items * @return */ public static <T extends Comparable<? super T>> List<T> sort(Collection<T> items) { List<T> list = toList(items); Collections.sort(list); return list; } /** * Sort the collection and return as list. * * @param items * @return */ public static <T> List<T> sort(Collection<T> items, Comparator<? super T> c) { List<T> list = toList(items); Collections.sort(list, c); return list; } /** * Convert the collection to linked list. * * @param items * @return */ public static <T> List<T> toList(Collection<T> items) { return new LinkedList<T>(items); } }