# whenCompared method

int whenCompared(

1. Object? o1,
2. Object? o2

)

Compares two objects using order metadata.

This method provides the actual comparison logic, handling both the standard comparison and the source provider-based comparison when configured.

### Parameters:

- `o1`: The first object to compare, may be null
- `o2`: The second object to compare, may be null

### Returns:

- `-1` if `o1` should come before `o2`
- `1` if `o2` should come before `o1`
- `0` if order is equal or both objects are null

### Null Handling:

- Null objects are treated as having the lowest possible precedence
- A non-null object always comes before a null object
- Two null objects are considered equal

## Implementation

    int whenCompared(Object? o1, Object? o2) {
      if (_comparator != null && o1 != null && o2 != null) {
        return _comparator!.compare(o1, o2);
      }
      return doCompare(o1, o2);
    }