33 lines
804 B
Python
33 lines
804 B
Python
|
def bublesort_multi_array(array):
|
||
|
for subarray in array:
|
||
|
sort_bubble_array(subarray)
|
||
|
swap = 1
|
||
|
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 sort_bubble_array(array): #merci votre td1
|
||
|
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 = bublesort_multi_array(array)
|
||
|
print(sorted_array)
|
||
|
|
||
|
|