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

	return minIdx;
}