<commit_before># https://youtu.be/P00xJgWzz2c?list=PLAB1DA9F452D9466C
# f(n) = c + n x c x n x c x c x c x c x c
# O(n^2), Θ(n^2), Ω(n^2)

def bubble_sort(items):
    number_of_sweeps_left = len(items)

    while number_of_sweeps_left > 0:
        number_of_sweeps_left -= 1

        for index, item in enumerate(items):
            if index == number_of_sweeps_left:
                break

            next_item = items[index + 1]
            if item > next_item:
                items[index] = next_item
                items[index + 1] = item

    return items<commit_msg>perf(bubble_sort/bubble_sort): allowed exit after ability to swap is exahausted<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# https://youtu.be/P00xJgWzz2c?list=PLAB1DA9F452D9466C
# f(n) = c + n x c x n x c x c x c x c x c
# O(n^2), Θ(n^2), Ω(n^2)


def bubble_sort(items):
    swapped = True
    sweeps_left = len(items)

    while sweeps_left > 0 and swapped:
        swapped = False
        sweeps_left -= 1

        for index in range(sweeps_left):

            item = items[index]
            next_item = items[index + 1]
            if item > next_item:
                items[index] = next_item
                items[index + 1] = item
                swapped = True

    return items
{'fraction_non_alphanumeric': 0.10641627543035993, 'fraction_numerical': 0.03051643192488263, 'mean_word_length': 2.0308056872037916, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3364654', 'n_tokens_mistral': 497, 'n_tokens_neox': 458, 'n_words': 121}