I have never systematically studied data structures and algorithms from the beginning.
Partial reference: http://interactivepython.org/courselib/static/pythonds/SortSearch/sorting.html
#-*-Coding: cp936-*-# insert sort def insertsort (a): for I in range (LEN (a)-1): # print, I For J in range (I + 1, Len (a): If a [I]> A [J]: temp = A [I] a [I] = A [J] a [J] = temp return a # Python's Bubble Sorting def bubblesort (alist ): for passnum in range (LEN (alist)-1, 0,-1): # print alist, passnum for I in range (passnum ): if alist [I]> alist [I + 1]: temp = alist [I] alist [I] = alist [I + 1] alist [I + 1] = temp return alist # select and sort def selectionsort (alist) in Python ): for I in range (LEN (alist)-1, 0,-1): maxone = 0 for J in range (1, I + 1 ): if alist [J]> alist [maxone]: maxone = J temp = alist [I] alist [I] = alist [maxone] alist [maxone] = temp return alistalist = [54,26, 93,17, 77,31, 44,55, 20] # print bubblesort (alist) alist = [54,26, 93,17, 77,31, 44,55, 20] print selectionsort (alist)