a = [2, 4, 3, 6, 1]
#升序排列
b = len(a)
for j in range(b):
key = a[j]
i = j - 1
while i >= 0 and a[i] > key:
a[i+1] = a[i]
i -= 1
a[i+1] = key
print(a)
#降序排列
j = 1
for j in range(b):
key = a[j]
i = j - 1
while i >= 0 and a[i] < key:
a[i+1] = a[i]
i -= 1
a[i+1] = key
print(a)