unsorted_array = [64, 25, 12, 22, 11]

def selection_sort(array)
  puts "Unsorted array: #{array.to_s}"

  array.length.times do |index|
    min = array[index..-1].min
    index_of_min = array.index(min)

    array[index], array[index_of_min] = array[index_of_min], array[index]

    puts "Iteration: #{index + 1} => #{array.to_s}"
  end

  puts "Sorted array: #{array.to_s}"
end

selection_sort(unsorted_array)
