Java Utililty Methods List Reverse

List of utility methods to do List Reverse

Description

The list of methods to do List Reverse are organized into topic(s).

Method

voidreverseUseList(int[] values)
reverse Use List
List<Integer> list = new ArrayList<Integer>();
for (int object : values) {
    list.add(object);
Collections.reverse(list);
Integer[] integers = list.toArray(new Integer[0]);
int i = 0;
for (int value : integers) {
...
ListreverseVector(List vector)
reverse Vector
Collections.reverse(vector);
return vector;
voidsortListBySublistSizeThenHead(List> list, boolean reverseOrder)
sort List By Sublist Size Then Head
Collections.sort(list, new Comparator<List<T>>() {
    @Override
    public int compare(List<T> o1, List<T> o2) {
        int size1 = o1.size(), size2 = o2.size();
        if (size1 == size2 && size1 > 0 && size2 > 0)
            return o1.get(0).compareTo(o2.get(0));
        return size1 - size2;
});
if (reverseOrder)
    Collections.reverse(list);
voidsortReverse(List list)
sort Reverse
Collections.sort(list, Collections.reverseOrder());
voidsortReverseOrder(List list)
sort Reverse Order
Collections.sort(list, Collections.reverseOrder());
ListtoReverse(List list)
to Reverse
List<T> ret = new ArrayList<>(list.size());
for (Iterator<T> itr = new LinkedList<>(list).descendingIterator(); itr.hasNext();) {
    T obj = itr.next();
    ret.add(obj);
return ret;