List of utility methods to do List Sort
List | sorted(List Return a copy of the list sorted according to the given comparator List<T> copy = new ArrayList<T>(l); Collections.sort(copy, comparator); return copy; |
List | sorted(List Sort the given list and return a reference to it Collections.sort(l);
return l;
|
List | sortedArray(List sorted Array return Arrays.asList(sortedArray(list.toArray()));
|
void | sortedInsert(List extends E> list, E e, Comparator super E> c) Inserts an element into a sorted list assert isSorted(list, c); int index = Collections.binarySearch(list, e, c); if (index >= 0) ((List<E>) list).add(index, e); else ((List<E>) list).add(-index - 1, e); assert isSorted(list, c) : list; |
int | sortedInsert(List Inserts the given item into the specified sorted list at the correct position given its sort order int insertIndex = Collections.binarySearch(list, item, comparator); if (insertIndex < 0) insertIndex = -(insertIndex + 1); list.add(insertIndex, item); return insertIndex; |
List | sortedList(List Returns a sorted version of the given list if (list == null || list.size() <= 1) { return list; ArrayList<T> ret = new ArrayList<>(); ret.addAll(list); Collections.sort(ret); return ret; |
List | sortedUnion(List args1, List args2) sorted Union SortedSet set = new TreeSet(); set.addAll(args1); set.addAll(args2); List lst = new ArrayList(set.size()); for (Iterator it = set.iterator(); it.hasNext();) { Object o = it.next(); lst.add(o); return lst; |
List | sortEntrySetToList(Set sort Entry Set To List List<Entry<Long, Long>> list = new LinkedList<Map.Entry<Long, Long>>(set); Collections.sort(list, new Comparator<Entry<Long, Long>>() { @Override public int compare(Entry<Long, Long> o1, Entry<Long, Long> o2) { if (o1.getValue() > o2.getValue()) return 1; if (o1.getValue() < o2.getValue()) return -1; ... |
void | sortIds(List Sorts the list of IDs. Collections.sort(ids); |
void | sortIfUnsorted(List sort If Unsorted int previous = Integer.MIN_VALUE; for (int i = 0; i < genomes.size(); i++) { if (genomes.get(i) < previous) { genomes.sort(null); return; previous = genomes.get(i); |