# ConvertingComparator<S, T> class

A comparator that compares source values of type `S` by first converting them to another type `T` using a Converter, then applying a Comparator on `T`.

This is useful when you want to sort values based on a derived property or a type transformation.

### 🔧 Example: Compare strings by their lengths

    final comparator = ConvertingComparator<String, int>(
      Comparator.naturalOrder(),
      Converter<String, int>((s) => s.length),
    );

    final list = ['pear', 'banana', 'kiwi'];
    list.sort(comparator); // ['kiwi', 'pear', 'banana']

You can also use the factory constructors:

### 🔧 Using `withConverter` and a ConversionService:

    final service = DefaultConversionService();
    final comparator = ConvertingComparator.withConverter<String, int>(
      Comparator.naturalOrder(),
      service,
      Class<int>(),
    );

Inheritance
  - Object
  - Comparator<S>
  - ConvertingComparator
Annotations
  - @Generic(ConvertingComparator)

## Constructors

ConvertingComparator.new(Comparator<T> _comparator, Converter<S, T> _converter)
  A comparator that compares source values of type `S` by first converting them to another type `T` using a Converter, then applying a Comparator on `T`.
ConvertingComparator.converter(Converter<S, T> converter)
  A comparator that compares source values of type `S` by first converting them to another type `T` using a Converter, then applying a Comparator on `T`.
ConvertingComparator.withConverter(Comparator<T> comparator, ConversionService conversionService, Class<T> targetType)
  A comparator that compares source values of type `S` by first converting them to another type `T` using a Converter, then applying a Comparator on `T`.

## Properties

hashCode → int
  The hash code for this object.
  no setter inherited
runtimeType → Type
  A representation of the runtime type of the object.
  no setter inherited

## Methods

compare(S a, S b) → int
  Compares two values of type `T` for order.
  override
noSuchMethod(Invocation invocation) → dynamic
  Invoked when a nonexistent method or property is accessed.
  inherited
reversed() → Comparator<S>
  Returns a comparator that imposes the reverse ordering of this comparator.
  inherited
thenComparing(Comparator<S> other) → Comparator<S>
  Chains another comparator to be used if this comparator returns 0 (equality).
  inherited
thenComparingComparable<U extends Comparable<U>>(U keyExtractor(S)) → Comparator<S>
  Chains a comparator by extracting a `Comparable` key from each element.
  inherited
thenComparingWith<U>(U keyExtractor(S), Comparator<U> keyComparator) → Comparator<S>
  Chains a comparator by extracting a key with `keyExtractor` and comparing it using the given `keyComparator`.
  inherited
toString() → String
  A string representation of this object.
  inherited

## Operators

operator ==(Object other) → bool
  The equality operator.
  inherited

## Static Methods

mapEntryKeys<K, V>(Comparator<K> comparator) → ConvertingComparator<MapEntry<K, V>, K>
  Creates a comparator that compares MapEntry objects by their keys.
mapEntryValues<K, V>(Comparator<V> comparator) → ConvertingComparator<MapEntry<K, V>, V>
  Creates a comparator that compares MapEntry objects by their values.