I will preface this with the follow: the method header was provided and i have to build around it for the assignment...i think i wouldve tackled this in a different way...but thats how school works i suppose

The point of this program is to return True if the array is sorted in ascending fashion, and False if descending/unsorted.
Code:
Code
public class Part1 {
public static void main(String[] args) {
Comparator<? super Object> comp = new Comparator<Object>() {
@Override
public int compare(Object o1, Object o2) {
return 0;
}
};
boolean ascending;
Integer[] array0 = {1, 2, 3, 4, 5};
System.out.println(ordered(array0, comp, true)); //Should print true
Integer[] array = {1, 2, 3, 4, 5, 3};
ascending = ordered(array, comp, true);
System.out.println(ascending); //Should print false
Integer[] array1 = {5, 4, 3, 2, 1};
System.out.println(ordered(array1, comp, true)); //Should print false
Integer[] array2 = {1, 5, 2, 4, 3};
System.out.println(ordered(array2, comp, false)); //Should print false
String[] array3 = {"a", "A", "c", "b"};
System.out.println(ordered(array3, comp, false)); //Should print false
}
public static<E>boolean ordered(E[] list, Comparator<? super E>comp, boolean ascending) {
if(ascending){
for (int i = 0; i < list.length - 1; i++) {
if (comp.compare(list[i], list[i + 1]) > 0) {
return false;
}
}
}
else {
for (int i = 0; i < list.length - 1; i++) {
if (comp.compare(list[i], list[i + 1]) < 0) {
return true;
} else if (comp.compare(list[i], list[i + 1]) > 0) {
return false;
}
}
}
return true;
}
}
Im pretty sure im missing something with the comparator, but im still new to using it and i cannot quite figure that one out. I understand that compare works as follows: 0 if o1=o2, -1 if o1<o2, and 1 if o1>o2.
That beings me to the ordered method, i tried it a few different ways (using a variable and returning it and all return statements as seen above). Neither seem to work properly...and it could be that im doing my return statements wrong, or that my comparator is incomplete.
Thoughts?