Here you can find the source of isStringListSortedDesc(List
Parameter | Description |
---|---|
list | List of strings |
public static boolean isStringListSortedDesc(List<String> list)
//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; } }