def clamp(value, minValue, maxValue):
    """Clamp value to the range minValue-maxValue.
	ValueError is raised, if minValue is bigger than maxValue.
	"""
    if minValue > maxValue:
        raise ValueError
    return max(min(value, maxValue), minValue)
