TD4_DEV51_rocherl/sorting.py
2024-11-26 12:15:13 +01:00

20 lines
628 B
Python

def sorting(array):
for sublist in array:
for i in range(len(sublist)):
for j in range(len(sublist) - i - 1):
if sublist[j] > sublist[j + 1]:
sublist[j], sublist[j + 1] = sublist[j + 1], sublist[j]
for i in range(len(array)):
for j in range(len(array) - i - 1):
sum_i = sum(array[j])
sum_j = sum(array[j + 1])
if sum_i > sum_j:
array[j], array[j + 1] = array[j + 1], array[j]
return array
array = [[0, 3, 2], [9, 4, 5], [4, 1, 3]]
sorted_array = sorting(array)
print(sorted_array)