def bubble_sort(list):
for i in range(len(list)):
for j in range(len(list)-1):
if list[j] > list[j+1]:
list[j], list[j+1] = list[j+1], list[j]
else:
continue
I just did this bubble sort, but I ended up realizing that it does some unnecessary interactions because of the greater (i), I would like to know how to stop all interactions when the list is sorted / know when the list is going to be sorted