ナポリタン

コードモンキー / 11

12 コメント
views
11
shisi 2025/12/03 (水) 11:57:30

150
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)

通報 ...