def bubble_sort(array):
    """
    Sort array in ascending order by bubble sort

    Bubble sort, sometimes referred to as sinking sort,
    is a simple sorting algorithm that repeatedly steps
    through the list, compares adjacent pairs and swaps
    them if they are in the wrong order.

    - Best-case time performance: O(n)
    - Worst-case time performance: O(n^2)
    - Average time performance: O(n^2)
    - Worst-case space complexity: O(1)

    :param array: given unsorted array
    :type array: list
    :return: sorted array in ascending order
    :rtype: list
    """
    # traverse through all array elements
    for i in range(len(array)):
        # traverse the array from 0 to n-i-1
        # last i elements are already in place
        for j in range(len(array) - i - 1):
            # swap if the element found is greater
            # than the next element
            if array[j] > array[j + 1]:
                array[j], array[j + 1] = array[j + 1], array[j]
    return array