argMaxBy<C extends Comparable<C> > method
Index of the element with maximum keyOf; null if empty.
Implementation
int? argMaxBy<C extends Comparable<C>>(C Function(T) keyOf) {
int? idx;
C? maxKey;
int i = 0;
for (final T e in this) {
final C k = keyOf(e);
if (maxKey == null || k.compareTo(maxKey) > 0) {
maxKey = k;
idx = i;
}
i++;
}
return idx;
}