我目前正在学习冒泡排序,并且已获得以下代码来解释:
numbers = [9,5,4,15,3,8,11]
numItems = len(numbers)
for i in range(0,numItems-2):
for j in range(0,numItems-i-1):
if numbers[j] > numbers[j+1]:
temp = numbers[j]
numbers[j] = numbers[j+1]
numbers[j+1] = temp
print(numbers)
我不理解这两个for循环,为什么它们是必需的以及它们做什么?