List of utility methods to do List Sort
boolean | isSorted(List extends Comparable> list) is Sorted return isSorted(list, true);
|
boolean | isSorted(List extends Comparable> list) Determine if the given list is sorted Comparable prevItem = null; for (Comparable currItem : list) { if (prevItem != null && currItem.compareTo(prevItem) < 0) { return false; prevItem = currItem; return true; ... |
boolean | isSorted(List is Sorted for (int n = 0; n < items.size() - 1; n++) { Comparable<T> current = items.get(n); Comparable<T> next = items.get(n + 1); int cmp = current.compareTo((T) next); if (asc && cmp > 0) { return false; } else if (!asc && cmp < 0) { return false; ... |
boolean | isSorted(List Checks that the list is sorted if (list.isEmpty()) return true; Iterator<E> i = list.iterator(); E lastR = i.next(); while (i.hasNext()) { E r = i.next(); if (c.compare(lastR, r) > 0) return false; ... |
boolean | isSorted(List Check a given list of String if it's sorted or not boolean sorted = true; for (int i = 1; i < list.size(); i++) { if (list.get(i - 1).compareTo(list.get(i)) > 0) { sorted = false; return sorted; |
boolean | isSorted(List checks wether or not the list given is sorted for (int i = 1; i < list.size(); ++i) { if (list.get(i - 1).compareTo(list.get(i)) > 0) { return false; return true; |
boolean | isSorted(List Returns whether a list is strictly sorted. T prev = null; for (T t : list) { if (prev != null && ((Comparable<T>) prev).compareTo(t) >= 0) { return false; prev = t; return true; ... |
boolean | isSortedDescending(List is Sorted Descending if (list.size() < 2) return true; for (int i = 1; i < list.size(); i++) { if (list.get(i - 1) < list.get(i)) { return false; return true; ... |
boolean | isStringListSortedDesc(List Determines of the data in a list is sorted in descending order boolean sorted = true; Iterator<String> iList = list.iterator(); String curr = iList.next(); while (iList.hasNext()) { String next = iList.next(); if (curr.compareTo(next) < 0) { sorted = false; break; ... |
boolean | isUnsortedEventsMatch(List is Unsorted Events Match if (actual.size() != expected.size()) { return false; } else { for (int i = 0; i < actual.size(); i++) { boolean isThere = false; for (int j = 0; j < expected.size(); j++) { if (Arrays.equals(actual.get(i), expected.get(j))) { isThere = true; ... |