You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
419 B
Python
14 lines
419 B
Python
def selectionSort(nlist):
|
|
for fillslot in range(len(nlist)-1,0,-1):
|
|
maxpos=0
|
|
for location in range(1,fillslot+1):
|
|
if nlist[location]>nlist[maxpos]:
|
|
maxpos = location
|
|
|
|
temp = nlist[fillslot]
|
|
nlist[fillslot] = nlist[maxpos]
|
|
nlist[maxpos] = temp
|
|
|
|
nlist = [14,46,43,27,57,41,45,21,70]
|
|
selectionSort(nlist)
|
|
print(nlist) |