#encoding:utf-8
def smallNum(arr):
small_index = 0
small = arr[0]
for i in range(1, len(arr)):
if arr[i] < small:
small = arr[i]
small_index = i
# return small
return small_index
def choseSort(arr):
new = []
for i in range(len(arr)):
sn = smallNum(arr)
# new.append(sn)
# arr.remove(sn)
new.append(arr.pop(sn))
return new
print choseSort([3,4,51,34,0])
网友评论