def swap(array, i, j)
    temp = array[i]
    array[i] = array[j]
    array[j] = temp
end

def index_of_min(array, start_index)
    min_value = array[start_index]
    min_index = start_index
    for i in (min_index + 1)...array.length
        if array[i] < min_value
            min_value = array[i]
            min_index = i
        end
    end
    return min_index
end

def select_sort(array)
    for i in 0...array.length 
        j = index_of_min(array, i)
        swap(array, i, j)
    end    
end

array = [4,2,1,5,3]
p array
select_sort(array)
p array

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: