List of utility methods to do Collection Sort
List | getSorted(Collection Return a sorted list with the collection's elements. List<T> ret = new ArrayList<T>(collection.size()); ret.addAll(collection); Collections.sort(ret); return ret; |
boolean | isSort(Collection is Sort E pointer = null, next; Iterator<E> it = c.iterator(); if (it.hasNext()) pointer = it.next(); while (it.hasNext()) { next = it.next(); if (pointer.compareTo(next) > 0) return false; ... |
void | sort(Collection collection) sort if (isNotEmpty(collection)) {
Object[] objs = collectionToArray(collection);
Arrays.sort(objs);
collection.clear();
collection.addAll(arrayToCollection(objs));
|
List | sort(Collection sort List<T> list = new ArrayList<T>(collection); Collections.sort(list, comparator); return list; |
List | sort(Collection Sort the collection and return as list. List<T> list = toList(items);
Collections.sort(list);
return list;
|
List | sortByDescendingOrder(Map sort By Descending Order List<Map.Entry<T, Double>> list = new ArrayList<Map.Entry<T, Double>>(collection.entrySet()); Collections.sort(list, new Comparator<Map.Entry<T, Double>>() { public int compare(Map.Entry<T, Double> o1, Map.Entry<T, Double> o2) { if (o1.getValue() > o2.getValue()) { return -1; } else if (o1.getValue() < o2.getValue()) { return 1; } else { ... |
List | sortClassesByLevelOfInheritance(Collection sort Classes By Level Of Inheritance List<Class<?>> result = new ArrayList<Class<?>>(classes); Collections.sort(result, new Comparator<Class<?>>() { public int compare(Class<?> c1, Class<?> c2) { int l1 = getLevelOfInheritance(c1); int l2 = getLevelOfInheritance(c2); if (l1 < l2) { return -1; } else if (l1 > l2) { ... |
List | sorted(Collection extends T> coll) sorted if (coll == null || coll.isEmpty()) { return Collections.emptyList(); List<T> list = new ArrayList<>(coll); Collections.sort(list); return list; |
List | sorted(Collection extends T> input) sorted List<T> sortable = new ArrayList<>(input); Collections.sort(sortable); return sortable; |
ArrayList | sorted(Collection sorted final ArrayList<E> result = new ArrayList<E>(coll); Collections.sort(result); assert result != null; assert result != coll; return result; |