def normalizeCellsByRows(cells, mode="max", valueExtractor=None):
    """All values in the table's rows are scaled so that:
    a) if mode='max', then maximum value in the row is 1 and all other are value/maxValue
    b) if mode='min', then minimum value in the row is 1 and all other are minValue/value
    """
    assert mode in {"max", "min"}
    if valueExtractor is None:
        valueExtractor = lambda x: x
    newCells = []
    for row in cells:
        newRow = []
        for value in row:
            value = valueExtractor(value)
            if value is None:
                newRow.append("-")
            elif mode == "max":
                maxValue = max(row)
                newRow.append("{:.2f}".format(value / maxValue))
            elif mode == "min":
                minValue = min(row)
                newRow.append("{:.2f}".format(minValue / value))
        newCells.append(newRow)
    return newCells