def bubblesort(x):
    """
    Sort array by looping through array, swapping unordered 
    adjacent elements until the array is sorted
    """
    assign, cond = 0, 0 # track assignments and conditionals
    swapped = True # variable to determine whether elements in array have been swapped
    assign += 1
    # continue sorting until array is looped through once and no swap is made
    while swapped == True:
        swapped = False
        assign += 1
        # loop through array 
        for i in range(0, len(x)-1):
            cond += 1
            # if elements are unordered swap them
            if x[i] > x[i+1]:
                temp = x[i]
                x[i], x[i+1] = x[i+1], temp
                swapped = True
                assign += 4
    return x, assign, cond