Android examples for java.util:Collection
Sort any collection and return a new list with it.
//package com.book2s; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.List; public class Main { /**// ww w .j a v a2s . c o m * Sort any collection and return a new list with it. Extremely useful while you need sorted map key/value pairs * @param c * @param comparator * @return */ public static <T> List<T> asSortedList(Collection<T> c, Comparator<T> comparator) { List<T> list = new ArrayList<T>(c); java.util.Collections.sort(list, comparator); return list; } }