ナポリタン

コードモンキー / 12

12 コメント
views
12
shisi 2025/12/03 (水) 12:36:04

149
def swap(swap_list, index_1, index_2):
    temp = swap_list[index_1]
    swap_list[index_1] = swap_list[index_2]
    swap_list[index_2] = temp

def bubble_sort(list_to_sort):
    for i in range(len(list_to_sort)-1,0,-1):
        for j in range(i):
            if list_to_sort[j].height > list_to_sort[j+1].height:
                swap(list_to_sort,j,j+1)

bubble_sort(flamingos)

通報 ...