def count_cmps(f, data, k):
    'Count comparisons in a call to f(k, data)'
    global cmps
    data = data[:]
    shuffle(data)
    cmps = 0
    result = f(k, data)
    assert result[:10] == list(range(10))
    return cmps
Count comparisons in a call to f(k, data)
recipes/Python/577573_Compare_algorithms/recipe-577573.py