def shootoutkey(row, col1=None, coldiff=None):
    """Calculate key for sorting a shootout.

row - a tuple (testname, results) where results is [(passing, ...), ...]
and passing is a truthy or falsy value.
col1 and col2 - indices into results

Return a tuple (col12same, col1fail, failcount) where
- col1fail is 0 if results[col1] passes else 1
- col12same is 1 if passing for results[col1] and results[col2]
  have same truthiness
"""
    testname, results = row
    fails = [0 if x[0] else 1 for x in results]
    col1fail = 0 if col1 is None else fails[col1]
    col2fail = 0 if coldiff is None else fails[coldiff]
    return col2fail == col1fail, col1fail, sum(fails)