mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 12:16:14 -04:00
16 lines
378 B
Python
16 lines
378 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
def bubble_sort(array)
|
|
|
|
has_swapped = True
|
|
|
|
while has_swapped:
|
|
has_swapped = False
|
|
|
|
for i in range(len(array) - 1):
|
|
if array[i] > array[i + 1]:
|
|
array[i], array[i + 1] = array[i + 1], array[i]
|
|
has_swapped = True
|