src/vs/base/common/arrays.ts/findMaxBy
export function findMaxBy<T>(items: readonly T[], comparator: Comparator<T>): T | undefined {
	if (items.length === 0) {
		return undefined;
	}

	let max = items[0];
	for (let i = 1; i < items.length; i++) {
		const item = items[i];
		if (comparator(item, max) > 0) {
			max = item;
		}
	}
	return max;
}