def median(seq):
    """Returns the median of a sequence.
    Note that if the list is even-length, then just returns the item to the left
    of the median, not the average of the median elements, as is strictly correct.
    """
    seq = sorted(seq)
    return seq[len(seq)//2]