MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / bubble_sort

Function bubble_sort

DemoPrograms/Demo_Sort_Visualizer.py:14–27  ·  view source on GitHub ↗
(arr)

Source from the content-addressed store, hash-verified

12
13
14def bubble_sort(arr):
15 def swap(i, j):
16 arr[i], arr[j] = arr[j], arr[i]
17 n = len(arr)
18 swapped = True
19 x = -1
20 while swapped:
21 swapped = False
22 x = x + 1
23 for i in range(1, n - x):
24 if arr[i - 1] > arr[i]:
25 swap(i - 1, i)
26 swapped = True
27 yield arr
28
29
30def draw_bars(graph, items):

Callers 1

mainFunction · 0.85

Calls 1

swapFunction · 0.85

Tested by

no test coverage detected