I'm implementing the `List` interface for a clone of `ArrayList`. I'm trying to implement `sort` ([source](https://docs.oracle.com/javase/8/docs/api/java/util/List.html#sort-java.util.Comparator-)):
[![java.util.List sort method](https://i.stack.imgur.com/7Y5yL.png)](https://i.stack.imgur.com/7Y5yL.png)
I'm not sure how to implement the case where the comparator is null. My `ArrayList` does not extend `Comparable` because I want to be able to store non-comparable objects in the list. I've tried using the following for the `sort` method:

```
public void sort(Comparator<? super E> c){
    if(c == null){
        // Use ascending order
        class ascComparator<T extends Comparable<? super T>> implements Comparator<T> {
            public int compare(T a, T b) {
                return a.compareTo(b);
            }
        }
        c = new ascComparator<E>();
    }
    // Implementation of merge sort goes here
}

```

This expectedly gives an error as `E` does not extend `Comparable`. In the above documentation it is stated "if ... is null then all elements in this list must implement the Comparable interface". How do I check that the objects in the list implement `Comparable` and how do I then use `compareTo` without getting an error? Is there just a better way to do this?