python&groovy冒泡排序
2020-12-13 03:45
标签:lis bre name str class nbsp 直接 list __name__ 无论天空有多高,踮起双脚就能靠近太阳 Groovy: 直接用sort(): class Example { Python: python&groovy冒泡排序 标签:lis bre name str class nbsp 直接 list __name__ 原文地址:https://www.cnblogs.com/citicto/p/11087242.html
static void main(String[] args) {
def lst = [13, 12, 15, 14];
def newlst = lst.sort();
println(newlst);
}
}
n = len(alist)
for i in range(0, n - 1):
count = 0
for j in range(0, n-i-1):
if alist[j] > alist[j + 1]:
alist[j], alist[j + 1] = alist[j + 1], alist[j]
count += 1
if 0 == count:
break
if __name__ == "__main__":
alist = [1, 3, 19, 29, 35, 56, 89]
print(alist)
bubble_sort(alist)
print(alist)