class ExtendedByTypesComparator implements Comparator<Object> {

  private final Comparator<Object> comparator;
  private final TypeComparators comparatorsByType;

  public ExtendedByTypesComparator(TypeComparators comparatorsByType) {
    this(
         new Comparator<Object>() {
           @Override
           public int compare(Object actual, Object other) {
             return Objects.deepEquals(actual, other) ? 0 : NOT_EQUAL;
           }

           @Override
           public String toString() {
             return "AssertJ Object comparator";
           }
         }, comparatorsByType);
  }

  public ExtendedByTypesComparator(Comparator<Object> comparator, TypeComparators comparatorsByType) {
    this.comparator = comparator;
    this.comparatorsByType = comparatorsByType;
  }

  @Override
  @SuppressWarnings("unchecked")
  public int compare(Object actual, Object other) {<FILL_FUNCTION_BODY>}

  public Comparator<Object> getComparator() {
    return comparator;
  }

  @Override
  public String toString() {
    // only used in element comparator
    return comparatorsByType.isEmpty()
        ? format("%s", comparator)
        : format("%s%n- for elements (by type): %s", comparator, comparatorsByType);
  }
}

    // value returned is not relevant for ordering if objects are not equal
    if (actual == null && other == null) return 0;
    if (actual == null || other == null) return NOT_EQUAL;

    @SuppressWarnings("rawtypes")
    Comparator comparatorByType = comparatorsByType == null ? null : comparatorsByType.getComparatorForType(actual.getClass());
    if (comparatorByType != null) {
      return other.getClass().isInstance(actual) ? comparatorByType.compare(actual, other) : NOT_EQUAL;
    }

    return comparator.compare(actual, other);
  
<no_super_class>