def shell_sort(array):
    """
    Sort array in ascending order by shell sort

    Shell Sort is mainly a variation of Insertion Sort.
    In insertion sort, we move elements only one position ahead.
    When an element has to be moved far ahead, many movements
    are involved. The idea of shellSort is to allow exchange
    of far items. In shell sort, we make the array h-sorted
    for a large value of h. We keep reducing the value of h
    until it becomes 1. An array is said to be h-sorted if
    all sub-lists of every h’th element is sorted.

    - Best-case time performance: O(n log n)
    - Worst-case time performance: O(n^2)
    - Average time performance: depends on gap sequence
    - Worst-case space complexity: O(1)

    :param array: given unsorted array
    :type array: list
    :return: sorted array in ascending order
    :rtype: list
    """
    # start with a big gap, then reduce the gap
    gap = len(array) // 2
    # do a gaped insertion sort for this gap size.
    # the first gap elements a[0..gap-1] are already in gaped
    # order keep adding one more element until the entire array
    # is gap sorted
    while gap > 0:
        for i in range(gap, len(array)):
            # add a[i] to the elements that have been gap sorted
            # save a[i] in temp and make a hole at position i
            key = array[i]
            j = i - gap
            # shift earlier gap-sorted elements up until the correct
            # location for a[i] is found
            while j >= 0 and key < array[j]:
                array[j + gap] = array[j]
                j -= gap
            # put temp (the original a[i]) in its correct location
            array[j + gap] = key
        gap //= 2
    return array