def bubble_sort(li):
    """ [list of int] => [list of int]
    Bubble sort: starts at the beginning of the data set.
    It compares the first two elements, and if the first is
    greater than the second, it swaps them. It continues doing
    this for each pair of adjacent elements to the end of the
    data set. It then starts again with the first two elements,
    repeating until no swaps have occurred on the last pass.
    """
    # boolean to keep track of whether the algorithm is sorted
    unsorted = True

    while unsorted:
        # assume it's sorted
        unsorted = False
        for i in range(len(li) - 1):
            if li[i] > li[i + 1]:
                # it is unsorted
                unsorted = True
                # swap elements
                li[i], li[i + 1] = li[i + 1], li[i]

    return li