MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / bubble_sort

Function bubble_sort

example_code/item_005.py:105–111  ·  view source on GitHub ↗
(a)

Source from the content-addressed store, hash-verified

103
104print("Example 7")
105def bubble_sort(a):
106 for _ in range(len(a)):
107 for i in range(1, len(a)):
108 if a[i] < a[i - 1]:
109 temp = a[i]
110 a[i] = a[i - 1]
111 a[i - 1] = temp
112
113names = ["pretzels", "carrots", "arugula", "bacon"]
114bubble_sort(names)

Callers 1

item_005.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected