Here you can find the source of isSorted(List
Parameter | Description |
---|---|
list | - List of Strings to be checked if it's sorted |
public static boolean isSorted(List<String> list)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { /**/*from www.j a va 2 s . c om*/ * Check a given list of String if it's sorted or not * * @param list - List of Strings to be checked if it's sorted * @return - true if sorted; false otherwise */ public static boolean isSorted(List<String> list) { 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; } }