# withSourceProvider method

Comparable<Object> withSourceProvider(

1. OrderSourceProvider sourceProvider

)

Configures this comparator instance to use the given OrderSourceProvider.

Unlike withSource, this method modifies the current instance rather than creating a new comparator. The source provider will be used for all subsequent comparisons made through this instance.

### Parameters:

- `sourceProvider`: The provider that resolves order sources for objects

### Returns:

This comparator instance for method chaining

### Example:

    final comparator = OrderComparator()
      .withSourceProvider(MyOrderSourceProvider());

    // Now uses the source provider for all comparisons
    items.sort(comparator.compare);

## Implementation

    Comparable<Object> withSourceProvider(OrderSourceProvider sourceProvider) {
      _comparator = Comparator.comparingWith<Object, int>((o1) => doCompare(o1, null, sourceProvider), Comparator.naturalOrder());
      return this;
    }