def cocktail_shaker_sort(collection):
    """
    鸡尾酒排序法(即:定向冒泡排序法)
    :param collection:
    :return:
    """
    for i in range(len(collection) - 1, 0, -1):
        swapped = False
        for j in range(i, 0, -1):
            if collection[j] < collection[j - 1]:
                collection[j], collection[j - 1] = collection[j - 1
                    ], collection[j]
                swapped = True
        for j in range(i):
            if collection[j] > collection[j + 1]:
                collection[j], collection[j + 1] = collection[j + 1
                    ], collection[j]
                swapped = True
        if not swapped:
            return collection
