The idea of choosing a sorting algorithm first first selects the smallest number from the entire sequence, then puts it first, then selects the smallest number from the second to the last, puts the number in the second position, and then, from the third to the last, selects the smallest of the numbers into the third position, so that it goes down until the last one. So that we can form an orderly sequence.
Select a value to compare, all compared, the maximum value is placed on the last side. And then continue to compare
#-*-encoding:utf-8-*-li=[1,2222,55555,12,31,32,13,23] forIinchRange (len (LI)): K=i#I equals the first position forJinchRange (I+1,len (LI)):#J equals a second position ifLI[K] > Li[j]:#If the first one is bigger than the second one ,LI[K],LI[J]=LI[J],LI[K]#Position SwapI= (#otherwise the position remains unchanged, followed by a continuation match. #at the end of each cycle, the maximum value is reachedPrint(LI)
Python Select sort