Java List Sort isStringListSortedDesc(List list)

Here you can find the source of isStringListSortedDesc(List list)

Description

Determines of the data in a list is sorted in descending order

License

Apache License

Parameter

Parameter Description
list List of strings

Return

Whether the list is sorted id descending order

Declaration

public static boolean isStringListSortedDesc(List<String> list) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Iterator;
import java.util.List;

public class Main {
    /**//from  w  w w .  ja  v a2  s  .c  om
     * Determines of the data in a list is sorted in descending order
     * 
     * @param list
     *            List of strings
     * @return Whether the list is sorted id descending order
     */
    public static boolean isStringListSortedDesc(List<String> list) {
        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;
            }
            curr = next;
        }
        return sorted;
    }
}

Related

  1. isSorted(List list, Comparator c)
  2. isSorted(List list)
  3. isSorted(List list)
  4. isSorted(List list)
  5. isSortedDescending(List list)
  6. isUnsortedEventsMatch(List actual, List expected)
  7. ListToSortedArray(List list)
  8. mapTosortedScoreList(HashMap unSortedMap)
  9. maximum(List sortedDataAscendingOrder)