标签:sort def int and 插入排序 self object pre %s
class InsertSort(object):
def __init__(self, data):
self.data = data
self.length = len(data)
def base_insert_sort(self):
data_list = self.data
for i in range(self.length - 1):
tmp = data_list[i]
j = i - 1
while j >= 0 and data_list[j] > tmp:
data_list[j + 1] = data_list[j]
j = j - 1
data_list[j + 1] = tmp
print('**%s' % (i+1), data_list)
return data_list
ii = InsertSort([9, 4, 6, 5, 11])
print(ii.base_insert_sort())
标签:sort def int and 插入排序 self object pre %s
原文地址:https://www.cnblogs.com/qiaoqianshitou/p/9928334.html