def median(iterable, sort=True):
    """Returns the value that separates the lower half from the higher half of
    values in the list."""
    s = sorted(iterable) if sort is True else list(iterable)
    n = len(s)
    if n == 0:
        raise ValueError('median() arg is an empty sequence')
    if n % 2 == 0:
        return float(s[n // 2 - 1] + s[n // 2]) / 2
    return s[n // 2]
