0
sorting a list
hi, i wrote this code for sorting a list. i don't want to use sort method. would you help me to correct it? def sorting(mylist): for i in range(0,len(mylist)): newlist=[] temp=0 if mylist[i]>mylist[i+1]: temp = mylist[i] mylist[i]=mylist[i+1] mylist[i+1]=temp newlist.append(temp) return newlist
1 ответ
+ 2
there are a lot of mistakes, i recomend reading this article about ths simplest sorting algorithm - bubble sort http://interactivepython.org/runestone/static/pythonds/SortSearch/TheBubbleSort.html