Quick actions

cmd+k|ctrl+k

Navigation

Languages

BubbleSort

Snippet info

Language

Python

Visibility

public

Author

chaosrock

Created

2016-09-14T18:05:23Z

Updated

2016-09-14T18:05:23Z

def bubble_sort(input_list):
    is_sorted = False
    while not is_sorted:
        is_sorted = True
        for (idx, num) in enumerate(input_list):
            if idx < len(input_list) - 1:
                if input_list[idx] > input_list[idx + 1]:
                    input_list[idx], input_list[idx + 1] = input_list[idx + 1], input_list[idx]
                    is_sorted = False
INFO