maxIndex method

int? maxIndex(
  1. Comparable compare(
    1. T
    )
)

Implementation

int? maxIndex(Comparable Function(T) compare) {
  if (isEmpty) return null;
  var max = this[0];
  var maxIndex = 0;
  for (var i = 1; i < length; i++) {
    if (compare(this[i]).compareTo(compare(max)) > 0) {
      max = this[i];
      maxIndex = i;
    }
  }
  return maxIndex;
}