pesanan naik dalam python menggunakan bubble sort
5
4
5
5
Lively Lizard
5
4
5
5
def bubble_sort(num):
for i in range(0,len(num)-1):
for j in range(len(num)-1):
if(num[j]>num[j+1]):
temp = num[j]
num[j] = num[j+1]
num[j+1] = temp
return num
num = [2, 1, 4, 5, 7]
print("The unsorted number: ", num)
print("The sorted number: ", bubble_sort(num))