def median(X):
    """
    Return the median of X
    """
    # sort the elements of X ascending first
    X_sorted = sorted(X)

    middle = len(X) // 2
    if len(X) % 2 == 0: # even number of elements
        return (X_sorted[middle] + X_sorted[middle-1]) / 2
    else:               # odd number of elements
        return float(X_sorted[middle])