标签:append min return turn python 列表 end ted sorted
本文转自TTT周清风,地址:https://www.cnblogs.com/tttzqf/p/9270509.html
def sort_list_method_1(a):
return sorted(a)
print(sort_list_method_1([1, 4, 2]))
def sort_list_method_2(a):
for i in range(len(a)):
m = i
for z in range(i+1, len(a)):
if a[m] > a[z]:
m = z
a[m], a[i] = a[i], a[m]
return a
print(sort_list_method_2([2, 4, 1]))
def sort_list_method_3(a):
b = []
for i in range(len(a)):
b.append(min(a))
a.remove(min(a))
return b
print(sort_list_method_3([4, 2, -2, 8]))
def sort_list_method_4(a):
return a.sort()
b = [4, 3, 7, -2, 1]
sort_list_method_4(b)
print(b)
标签:append min return turn python 列表 end ted sorted
原文地址:https://www.cnblogs.com/cbma0116/p/11881159.html