Python Selection Sort and Open Source

I jumped on the chance to submit a pull-request for an example of Selection Sort in Python, and somebody beat me to it :)

I love algorithms and data structures so I don’t want the sample to go to waste.

def selection_sort(arr):
    """
    In-place sort using Selection Sort.

    Space Complexity: O(1)
    Time Complexity: O(n^2)
    Stable: No

    :param arr: list of values
    :return: None
    """
    if arr is None or len(arr) < 2:
        return arr

    for i in range(len(arr) - 1):
        min_index = i
        for j in range(i+1, len(arr)):
            if arr[j] < arr[min_index]:
                min_index = j
        arr[min_index], arr[i] = arr[i], arr[min_index]


values = [1, 4, 7, 45, 7, 43, 44, 25, 6, 4, 6, 9]
selection_sort(values)
print(values)

I just realized you can see a sample of Bubble Sort in Python from my Hacktoberfest article!