Java tutorial
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.List; 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); } return sorted; } }