src/vs/base/common/arrays.ts/maxIndex
export function maxIndex<T>(array: readonly T[], fn: (value: T) => number): number {
	let minValue = Number.MIN_SAFE_INTEGER;
	let maxIdx = 0;
	array.forEach((value, i) => {
		const thisValue = fn(value);
		if (thisValue > minValue) {
			minValue = thisValue;
			maxIdx = i;
		}
	});

	return maxIdx;
}