import copy


def quick_sort(data, reverse=False):
    """
    Implement quick sort.
    :param data: []
    :param reverse: if reverse is True, DESC, else ASC.
    :return: []
    """
    iter(data)
    copy_data = copy.deepcopy(data)
    if len(copy_data) < 2:
        return copy_data
    equal = []
    left = []
    right = []
    center_index = len(copy_data) // 2
    center_value = copy_data[center_index]
    for item in copy_data:
        great_or_less = item > center_value if reverse else item < center_value
        if item == center_value:
            equal.append(item)
        elif great_or_less:
            left.append(item)
        else:
            right.append(item)
    left_ = quick_sort(left, reverse)
    right_ = quick_sort(right, reverse)
    return left_ + equal + right_