forked from menault/TD4_DEV51_Qualite_Algo
30 lines
788 B
Python
30 lines
788 B
Python
def bubblesort_multi_array(array):
|
|
for subarray in array:
|
|
bubblesort_array(subarray)
|
|
while (swap > 0):
|
|
swap = 0
|
|
for i in range(1,len(array)):
|
|
if sum(array[i-1])>sum(array[i]):
|
|
temp = array[i-1]
|
|
array[i-1]= array[i]
|
|
array[i] = temp
|
|
swap += 1
|
|
|
|
return array
|
|
|
|
def bubblesort_array(array):
|
|
swap = 1
|
|
while (swap > 0):
|
|
swap = 0
|
|
for i in range(1,len(array)):
|
|
if array[i-1]>array[i]:
|
|
temp = array[i-1]
|
|
array[i-1]= array[i]
|
|
array[i] = temp
|
|
swap += 1
|
|
|
|
|
|
# testt
|
|
array = [[0, 3, 2], [9, 4, 5], [4, 1, 3]]
|
|
sorted_array = bubblesort_multi_array(array)
|
|
print(sorted_array) |