Java examples for java.util:Collection Compare
sort a Collection by Comparator
//package com.java2s; import java.util.*; public class Main { public static <T> List<T> sort(final Collection<T> collection, final Comparator<T> comparator) { final List<T> sorted = new ArrayList<T>(collection); if (sorted.size() > 1) { Collections.sort(sorted, comparator); }/*w w w . j av a 2s .c om*/ return sorted; } }