Selection Sort Visualizer

COSC 2306: Data Programming - Selecting Maximum Strategy

Fill Slot --
Current Max
Comparing
Sorted
Press "Step Forward" to find the largest value for the current fill slot.

Algorithm Trace

# Selection Sort ready.
# Goal: Find max in unsorted range and move to fill slot.

Controls

Python Implementation (Lecture)
def selection_sort(a_list):
    for fill_slot in range(len(a_list)-1, 0, -1):
        pos_of_max = 0
        for location in range(1, fill_slot + 1):
            if a_list[location] > a_list[pos_of_max]:
                pos_of_max = location

        temp = a_list[fill_slot]
        a_list[fill_slot] = a_list[pos_of_max]
        a_list[pos_of_max] = temp