Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
HW. Bubble Sort Descending Order
#python 3.5.2 print ("Hello, world!") def bubbleSort(alist): length = len(alist) for passnumber in range(0, length): # number of passes = N - 1 print ('Passnumber: ', passnumber) for i in range((length-1) ,0,-1 ): # loop for bubbles print ('Possible values for i:',i) if alist[i] > alist[i-1]: temp = alist[i] # temp = 89 alist[i] = alist[i-1] # 89 with 5 alist[i-1] = temp # 89 => 5 print (i,'-->',alist) print () print ('------------------------------------------------') return alist sampleList = [1, 5, 89, 8, 23, 1] sortedList = bubbleSort(sampleList) print (sortedList)
run
|
edit
|
history
|
help
0
Rene
inverse matrix gauss jordan
guess123
Ex_039.py
числа близнецы
Python if condition
"Hello,world!"
p1
gj2
PyTypeClass