MCPcopy Create free account
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / bubbleSort

Function bubbleSort

BubbleSort.py:2–7  ·  view source on GitHub ↗
(alist)

Source from the content-addressed store, hash-verified

1# Python 实现冒泡排序
2def bubbleSort(alist):
3 for passnum in range(len(alist)-1, 0, -1):
4 for i in range(passnum):
5 if alist[i] > alist[i+1]:
6 alist[i], alist[i+1] = alist[i+1], alist[i]
7 return alist
8
9alist = [54,26,93,17,77,31,44,55,20]
10print(bubbleSort(alist))

Callers 1

BubbleSort.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected