Checks whether the array is sorted in ascending order. @param array the array to check @return true if the array is sorted in ascending order, false otherwise
(T[] array)
| 96 | * @return true if the array is sorted in ascending order, false otherwise |
| 97 | */ |
| 98 | public static <T extends Comparable<T>> boolean isSorted(T[] array) { |
| 99 | for (int i = 1; i < array.length; i++) { |
| 100 | if (less(array[i], array[i - 1])) { |
| 101 | return false; |
| 102 | } |
| 103 | } |
| 104 | return true; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Checks whether the list is sorted in ascending order. |