def getBest(arr, getterFunc, takeMax):
    """
        Will return a tuple of the
            index and the value of the best
            as extracted by getterFunc
    """
    theBest = None
    theBestOriginalVal = None
    for originalVal in arr:
        val = getterFunc(originalVal)
        if theBest is None:
            theBest = val
            theBestOriginalVal = originalVal
        isBetter = False
        if takeMax:
            if val > theBest:
                isBetter = True
        elif val < theBest:
            isBetter = True
        if isBetter:
            theBestOriginalVal = originalVal
            theBest = val
    return theBestOriginalVal, theBest
