maxBy method

T maxBy(
  1. Comparator<T> comparable, {
  2. T orElse()?,
})

return max by comparable

Implementation

T maxBy(Comparator<T> comparable, {T Function()? orElse}) {
  if (isEmpty) return (orElse ?? _throwNotFound)();

  return reduce(
    (value, element) => comparable(value, element) > 0 ? value : element,
  );
}